【发布时间】:2022-12-21 09:48:30
【问题描述】:
我尝试通过在 ECL 中使用 HTTPCALL 来访问 API,但它给出了以下错误。
我试过用 Postman 打它,它在里面工作得很好。 这是 API 的 URL - 'https://api.waqi.info/feed/geo:10.3;20.7/?token={token}' 和示例代码:
IMPORT STD;
EXPORT callAirNow() := FUNCTION
/*
This is a API call from https://aqicn.org/
Web Services API https://aqicn.org/json-api/doc/
*/
Forcast_Rec := RECORD
INTEGER AQI {xpath('aqi')};
END;
resultWrapper := RECORD
DATASET(Forcast_Rec) wrap {xpath('/data')};
END;
URL := 'https://api.waqi.info/feed/geo:10.3;20.7/?token={token}';
MakeCall := HTTPCALL(URL, 'GET', 'application/json', resultWrapper, XPATH('/'));
// Extracting child dataset
RETURN MakeCall.wrap;
END;
output(callAirNow());
【问题讨论】: