Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Fernando_Fabregas
Creator II
Creator II

Rest API - JSON - Error 500 - How to remove spaces and line breaks ?

Hi !
I'm trying to import data from a Qlik Sense app using a REST API connector, and when creating the REST connector, I get "HTTP protocol error 500 (Internal Server Error): {"error":"Internal Server Error: null","status":500}".

The JSON format to be imported is like this:
[
  {"id":"1",
   "modulo":"ERP",
   "version":"6.1"
  },
   {"id":"2",
    "modulo":"CRM",
    "version":"8.2"
   }
]

The strange thing is that when importing from another version of the same API, which returns a compact JSON format (without spaces or line breaks between fields), it works perfectly, both when creating the REST connector and via script.
The format that works well is this:
[{"id":"1", "modulo":"ERP", "version":"6.1"},
{"id":"2", "modulo":"CRM", "version":"8.2"}]

Both endpoints are visible from Qlik, don't require pagination, and have the correct authentication and parameters. Both JSONs has no hierarchical structure, and the result output is about 400 records.

I'm using client managed Qlik Sense Enterprise February 2023 Patch 2, qliksenseserver: 14.113.4

This script works well with the compact JSON API, but does not work with the JSON API with breaks and spaces.

LIB CONNECT TO 'Rest_Api';

RestConnectorMasterTable:
SQL SELECT
   "id",
   "module",
   "version"
FROM JSON (wrap on) "root"
WITH CONNECTION
( Url "https://xxx.xxx.com/api/reports/modulos?FechaDesde=2024-01-01&ACCESS_TOKEN=xxxxxxxxxxxxxxxxxxxxx");

Report:
LOAD
   id,
   module,
   version
RESIDENT RestConnectorMasterTable;

DROP TABLE RestConnectorMasterTable;

Does anyone know how to remove spaces and line breaks from JSON preferably from Qlik Sense ? I need to access many APIs, and modifying them all isn't the best option.

Thanks in advance.

Regards,
Fernando

Labels (5)
3 Replies
henrikalmen
Specialist II
Specialist II

I would think that the error message you are getting is from the rest api server, not from Qlik. Therefore, there's nothing you can do in qlik as a workaround (unless you can specify a parameter in the request that will make the api return the data in the compact format without line breaks).

Did you try to fetch the data with e.g. Postman instead of Qlik, to see if you are getting the same error message?

Fernando_Fabregas
Creator II
Creator II
Author

Hi Henri, thanks for the reply.
I tried it from a browser and it works fine, I fetch de data correctly.

If possible, I'll be testing from Qlik Cloud and contacting the API provider to resolve the issue outside of Qlik.
If I find a solution, I'll post it here and close the post.

 

henrikalmen
Specialist II
Specialist II

Have you tried verifying the json data in a json validator such as jsonchecker.com ?