Skip to main content
Announcements
Introducing a new Enhanced File Management feature in Qlik Cloud! GET THE DETAILS!
cancel
Showing results for 
Search instead for 
Did you mean: 
Fernandez
Creator II
Creator II

How to call REST WS with JSON ?

Hi,

I tried all what is explained in the posts found in the forum but nothing works...

I want to call a REST WS with a JSON body like :

   {

    "format": "application/json",

    "system": "euro",

    "companyId": "1234",

    "customerId": "CH003",

    "filter": {

    "boxNumber":"331135738"

    }

   }

Test n°1 : with Component tRestClient

   0695b00000N45TmAAJ.png

   0695b00000N45VOAAZ.png

   Result

   0695b00000N45WCAAZ.png

Test n°2 : with Component tRest

   0695b00000N45WMAAZ.png

   0695b00000N45XAAAZ.png

   

   Result

   

   <html><body><h1>Whitelabel Error Page</h1>

   <p>This application has no explicit mapping for /error, so you are seeing this as a fallback.</p>

   <div id='created'>Tue Feb 01 02:59:48 EST 2022</div>

   <div>There was an unexpected error (type=Internal Server Error, status=500).</div>

   <div>Servlet execution threw an exception</div>

   </body></html>|500

   

Thanks for any help !

Labels (6)
1 Solution

Accepted Solutions
Anonymous
Not applicable

You are nearly there. There is an extra step which you need to keep in mind. The tRestClient has a fixed inbound schema (body and string). For JSON, you need to send the data to the "string" column. The "body" column is for XML documents. The way to go about this is to first make sure your JSON String is perfect. To do this, output from the tWriteJSONField to a tLogRow and take a look. This needs to be precisely as specified by the API. Once you are happy with that, it needs to be sent to the "string" column.

 

If that doesn't get you any closer, could you post the API specification so that we can look at that? Web Services can be pretty tricky to get right sometimes.

View solution in original post

2 Replies
Anonymous
Not applicable

You are nearly there. There is an extra step which you need to keep in mind. The tRestClient has a fixed inbound schema (body and string). For JSON, you need to send the data to the "string" column. The "body" column is for XML documents. The way to go about this is to first make sure your JSON String is perfect. To do this, output from the tWriteJSONField to a tLogRow and take a look. This needs to be precisely as specified by the API. Once you are happy with that, it needs to be sent to the "string" column.

 

If that doesn't get you any closer, could you post the API specification so that we can look at that? Web Services can be pretty tricky to get right sometimes.

Fernandez
Creator II
Creator II
Author

Thanks for your help.

It's running fine.