- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hello everyone, I would like to ask some questions.
I usually use SAS Studio to call data from API. That API made by my colleague has a 10 thousand maximum data to reduce chance of connection loss because of the big number. But sometimes, the data inside is more than 10 thousand, so they made paging for every 10 thousand data. The API would look like this:
https://site.com/admin/api/v1/survey?ID=111111&type=long&page=1
When I don't use the page parameter, it would works just fine. But when I use the page parameter when the data is over 10 thousand, this error show up.
SyntaxError: Unexpected end of JSON input
The code that I used to call the data:
FILENAME request HTTP
'https://site.com/admin/api/v1/survey?surveyID=111111&type=long&page=1'
user='user@user.com' password='user123' debug;
DATA NULL;
INFILE request;
INPUT;
PUT INFILE;
RUN;
libname test1 JSON fileref=request;
data work.data_testing;
set test1.root;
run;
At first, I thought the error would be in the API links. But when I check one by one for every page, it open just fine.
Is there any solution for this? Or is this error caused by API side?
Thanks.
- Tags:
- HTTP API JSON
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Because this works OK without the page parameter, I'd suspect the API. Perhaps it isn't properly terminating the JSON object for each page when paginating the results.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
This error almost always indicates malformed JSON or a response that is NOT JSON at all (like a 404 HTML response page). So I have questions:
1. When does the error you specified occur?
2. Is the error generated by SAS? If so, is it from the PROC HTTP step, the LIBNAME statement, or the DATA step?
3. Have you looked at the raw JSON file to see if you can identify the problem?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Maybe not helping with the current issue, but if you have issues with data transfer size, timeouts etc, you may should look into other solutions such as file transfer, queuing/messaging (e.g. Kafka).