Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Is there a way to take care of the response body information when the API returns 4xx response code?
In my case, the API I'm using responds with a highly relevant error message along with the 4xx status code. If I could parse the body of that error message, I could let the script fix the error that is mentioned and retry the request. But I can't find a way to retrieve that response, the rest connector raises a script error and I can't seem to get any information into QlikView from that response when the connector encounters this error.
Error handling in QV does not seem to do the trick. If I do this:
trace $(ScriptError) # $(ScriptErrorDetails)
I get this:
File Has Wrong Format # QVX_UNEXPECTED_END_OF_DATA: The remote server returned an error: (404) Not Found.
But the actual response body from the server is the following, and I really want to get the value of the message parameter:
{
"error": {
"code": "item.not-found",
"message": "Item with id 440313 was not found",
}
}
@henrikalmen Did you ever resolve this? I would like to do something similar on our side - pull in the error codes and provide in a MIS Dashboard
I was able to pull something out of the ScriptErrorDetails variable. We're using QlikSense however - version Nov 2018. So maybe this is implemented correctly in there.
Thanks for the post - I don't see anything in Qlik Help regarding ScriptErrorDetails ...
Same here - I've tried every trick in the book. Seems to me there is no work-around to actually retrieve non-successful response code message content from the REST connector and no out of the box work-around. On a similar vein, I've also hit a hard block on trying to fetch a redirect message body e.g. 301/302 status code responses. There is supposed built-in support for automatically resolving/following redirects, but in my case attempting to fetch data from various scm repos, like github / bitbucket, it does not work out of the box and I can't build a work-around as I have no way of manually processing the response.
@Bjorn_Wedbratt I noticed you've provided great intel on REST connector related posts before, maybe this is something you could comment upon and/or promote internally for future enhancement? I.e. open up for the REST connector to return non 200 status code response bodies, rather than just throwing a Qlik error? This way a Qlik developer could have an opportunity to deliver customized message and/or error handling.
Thanks for the attention, here's hoping the connector can be improved!
Hi @JonasValleskog , sorry about the delay in response.
I brought this up internally as I agree, the REST Connector should return the Json response even for non 200 status codes, like 404, 401, etc (https://postman-echo.com/status/401 as a simple example). It's not that uncommon the API developer is providing additional details back in the response body, which ideally should be picked up if ErrorMode=0
I suggest to raise this in Ideas, https://community.qlik.com/t5/Suggest-an-Idea/idb-p/qlik-ideas to have it voted upon and priorities as customer/partner request
Best,
Bjorn