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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Create Restfull Service with method POST

Hi all,
I have to create a Rest Service with method POST. This service, for the moment, hasn't input and returns a JSON that I have set from a file like shown in figures.
I tried this service by Rest Client, but it returns status code "415 Unsupported Media Type".
Someone could show me an example with method post?
thanks
0683p000009MBXQ.png 0683p000009MBTh.png 0683p000009MBbK.png
Labels (4)
7 Replies
Anonymous
Not applicable
Author

Hi
You have the endpoint that expects HTTP Content-Type set to application/json or application/xml, 415 would be returned if it is set to something else, example, some clients may set a form Content-Type if no Content-Type is set.
HTH, Sergey
Anonymous
Not applicable
Author

Hi,
if I want to send a JSON input to Rest Service, as shown in figure, how Can I set the JSON in the rest client??
{"file":"content"}

Is it correct?
0683p000009MBa8.png 0683p000009MBXA.png
Anonymous
Not applicable
Author

Hi, I guess you have 2 options:
- set tRESTClient body type to String and use a tWriteJsonField component
- use tXmlMap to build XML tree and then let tRESTClient auto-convert it to JSON, keep the body type as Document
Cheers, Sergey
Anonymous
Not applicable
Author

Hi Sergey,
I don't use tRestCLient, but I want to use Advanced Rest Client. For this reason, I have to know the format for the JSON to send to Service.
Anonymous
Not applicable
Author

Hi, it depends on what format tRESTRequest expects.
If it has to be
{"file":"content"}

then have Advanced Rest Client produce it,
Cheers, Sergey
Anonymous
Not applicable
Author

I tried by advanced rest client with:
{"file":"content"}

but it return status code "415 Unsupported Media Type".
Why? How have to configure tRestrequest?
thanks a lot.
Anonymous
Not applicable
Author

First of all, can you please vote for
https://jira.talendforge.org/browse/TESB-15346
OK, so you have this JSON payload. The 1st thing that needs to be done is to have it mapped to a schema parameter called 'body' - so add a 'body' parameter there of either String or Document type.
If you choose String - it means you need to process it with one of components which can take a JSON string and process it,
If you choose Document - it means tRESTRequest will try to auto-convert JSON into a Document which you can later process with tXMLMap, etc.
In this specific case make sure you set tRESTRequest wrap json sequence property to true to get the auto-conversion working.
Please also make sure Advanced Rest Client sets Content-Type to application/json - one way to check is to enable TRESTRequest to log the incoming requests
HTH, Sergey