Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
SBN
Contributor III
Contributor III

How to handle "NULL" response in REST API Connector

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:

SBN_0-1683548612457.png

The response headers show that it's a json content type response:

SBN_1-1683548678568.png

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

Labels (4)
1 Solution

Accepted Solutions
williejacobs
Creator
Creator

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';

 

View solution in original post

3 Replies
williejacobs
Creator
Creator

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';

 

SBN
Contributor III
Contributor III
Author

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.

williejacobs
Creator
Creator

Hi @SBN 

Yes, you are right.

Glad I could help.

Regards,

Willie.