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

Announcements
Qlik and ServiceNow Partner to Bring Trusted Enterprise Context into AI-Powered Workflows. Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
DBS1
Contributor III
Contributor III

The REST API response is coming in weird format

Hi team

I am able to obtain the JSON response as part of an API GET request via postman.
I am using the same headers in tREST as well as tRESTClient components, I am getting the status code as 200 but the body, I am not getting as JSON format instead I am getting in some decoded format or something.

How to resolve this issue and how to obtain the response in exact JSON format.

Thanks

DBS 

Labels (3)
3 Replies
hajraboba
Contributor
Contributor

I think the actual data isn't in the right JSON format like you expected. This could be because of how the data is being encoded or sent back from the API. To fix this, check the headers you're sending with your request to make sure they match what the API expects. Specifically, look at the "Content-Type" header and make sure it says "application/json". This tells the API you want the data in JSON format. If it still doesn't work, take a closer look at the response body itself to see if there are any strange characters or codes that might need to be decoded or handled differently. Adjusting these settings should help you get the API response in the correct JSON format and it works on every other app as well, like you can also implement it on some streaming platforms like Netflix and DixMax app. Hope this works.

nicolesilvera
Contributor
Contributor

It looks like the API response isn’t in proper JSON format. Make sure your request headers include Content-Type: application/json so the API knows to send JSON. If it still fails, check the response body for unusual characters or encoding issues. Fixing these should make the data work correctly, just like it does on other apps and streaming platforms like Netflix or magis app. we hope this will work better. 

Greg_Taffer
Support
Support

The "decoded format" you are seeing is likely Talend's internal Document type (XML representation) or a Base64 encoded string, which tRESTClient often uses by default for response handling. 
 

To resolve this and obtain an exact JSON format, follow these steps:
 

1. Disable Automatic XML Conversion (tRESTClient)

By default, tRESTClient attempts to convert JSON responses into a DOM document (XML) for easier mapping in Talend's ESB components. 

  • Go to the Advanced settings tab of your tRESTClient component.
  • Uncheck the box "Convert response to DOM document".
  • This forces the component to return the raw response in the string field of the output schema instead of the body (Document) field. 

2. Configure the Accept Type

Ensure the component explicitly requests JSON from the server to match your Postman configuration

  • In the Basic settings tab of tRESTClient, set the Accept Type to JSON.
  • If you are using tREST, ensure you have an Accept header with the value application/json in the HTTP Headers table. 

3. Access the Correct Output Column

The tRESTClient component has a fixed output schema with three main columns: statusCode, body, and string. 

  • Use the string column: This column contains the raw JSON string.
  • Avoid the body column: Unless you specifically need a Document type for tXMLMap, this column will often appear empty or "decoded" if the conversion settings are incorrect. 

4. Handle Gzip Compression (If Applicable)

If your API returns compressed data, tRESTClient may sometimes fail to decode it properly in the Error flow, though it usually handles it for successful 200 OK responses. 

  • For more robust handling in newer Talend versions, consider using the tHTTPClient component, which provides more direct control over JSON body extraction. 

Summary Workflow:
tRESTClient (Uncheck 'Convert response to DOM') -> tExtractJSONFields (Link to 'string' column) -> tLogRow.