Error when trying to hit an API using HTTPCALL in ECL

73 views Asked by At

I try to hit the API by using HTTPCALL in ECL and it is giving following error. enter image description here

I have tried hitting it using Postman, its working fine in it. Here is the URL for API - 'https://api.waqi.info/feed/geo:10.3;20.7/?token={token}' and sample code:

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());
1

There are 1 answers

0
Richard Taylor On

Once I removed the XML space encoding, that error message reads as:

bad net addr CSocket::pre_connect - Invalid/missing host IP address raised in: jsocket.cpp, line 869

Since this URL works for you in Postman, I suggest you submit a JIRA ticket (https://track.hpccsystems.com) to report the issue -- it looks to me like it may be a bug in the jsocket.cpp code that needs squashing.