Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi fellow Qlik enthousiasts,
I'm connecting Qlik Sense to a REST API through the REST API Connector.
The first connector refreshes the Bearer token with a post request and serves this token in a variable to the second connector to get the information.
The REST API requires a mandatory year and month parameter in the URL:
https://apiurl/v1/feedbackData?year=2023&month=5
I've managed to create a load script that runs through a number of years and months, but throws the following error when it encounters a month without any data: "Unable to parse the input JSON: PropertyName token is expected.".
When I use Postman to test this particular month it shows me the following result:
The response headers show that it's a json content type response:
But as you can see the body is empty.
My load script starts with the following:
---------------------------------------------------------------------
[FeedbackDataTemp]:
SQL SELECT
"__KEY_root",
(SELECT
"__FK_feedbackData",
"__KEY_feedbackData",
(SELECT
"id" AS "id_u5",
"date",
"email",
"formatId" AS "formatId_u0",
"unitId",
"transactionCode",
"customerCode",
"lastName",
"gender",
etc.
WITH CONNECTION (
URL "$(vApiURL)",
HTTPHEADER "Authorization" "Bearer $(APIToken)",
HTTPHEADER "Accept" "application/json;charset=utf-8"
);
---------------------------------------------------------------------
In case of an "empty" response these fields are not available and than I guess the connector throws this error.
What can I do to detect the empty response?
Kind regards,
SBN
Hi @SBN,
Maybe try to change error mode, this should ignore the error and go to the next variable/month.
Before the rest extract
Set = errormode = '0';
Hi @SBN,
Maybe try to change error mode, this should ignore the error and go to the next variable/month.
Before the rest extract
Set = errormode = '0';
Hi @williejacobs,
Thank you for the suggestion.
I didn't know this setting.
Documentation can be found here for anyone else that comes across this question and is interested:
ErrorMode | Qlik Sense on Windows Help
I've tried this and now I've managed to download all records from the start because Qlik will ignore the error and keeps running the script until it's finished.
Thanks!
I guess you can set the errormode back to 1, the default value, again after this REST API Do...Loop loading script so that if there are any other unforeseen errors the script will fail.
Am I right?
Kind regards,
SBN.