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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
rubenfasilva
Contributor
Contributor

From json file to tRESTClient one request only

Hello.

I have a simple job with a json file structed like this:

[

{

    "sku" : "A",

    "warehouse" : "NY",

    "qty" : 2

},

{

    "sku" : "B",

    "warehouse" : "CA",

    "qty" : 3

},

{

    "sku" : "C",

    "warehouse" : "LA",

    "qty" : 1

 }

]

That I would like to post on a website using trestclient with one request only instead one request per line.

My job is:

tfileinputjson -> txmlMap -> trestclient

0695b00000aEhmoAAC.png

Is possible to make one request only?

Labels (4)
23 Replies
rubenfasilva
Contributor
Contributor
Author

Hello.

Stocks file is the struture in json.

If I use it as raw, I have no answer from API:

200||{"data":[{"status":"error","error":"No data received","erp_transaction_id":null}]}

 

 

 

Anonymous
Not applicable

Can you show me the job design and how the components are configured please? You should not be sending no data unless there is something wrong with how the components are configured. If the components are configured correctly, then we will need to look at what your API is expecting.

rubenfasilva
Contributor
Contributor
Author

Hello.

From a csvfileinput I am generating json file(stocks.json) with the required structure.

Then I am trying to make the post using the stocks.json file to the API

0695b00000aFfekAAC.pngThis is the json file input:

 

0695b00000aFfepAAC.pngThis is the txmlmap:

0695b00000aFff4AAC.png 

Thank you

 

Anonymous
Not applicable

The tXMLMap is the wrong component. That produces XML and not JSON.

 

I was hoping you would show me the job where you tried my suggestion. The way you're doing the above will not work at all if your API requires JSON.

rubenfasilva
Contributor
Contributor
Author

Hello

If i do your suggestion I have this response:

200||{"data":[{"status":"error","error":"No data received","erp_transaction_id":null}]}

This i what I did:

0695b00000aFg1eAAC.png 

This is the tmap config:

 

0695b00000aFg1tAAC.png 

I am stuck....

 

 

Anonymous
Not applicable

You need to send JSON to the "string" column. "body" is for XML, "string" is for JSON. Although XML looks like a String, it is handled differently. JSON is just handled as a String.

rubenfasilva
Contributor
Contributor
Author

Hello.

I did that now and I have this response:

statusCode body string

200||{"data":[{"status":"error","error":"No data received","erp_transaction_id":null}]}

 

This is my job:

 

 

0695b00000aFiSEAA0.png 

My tmap:

0695b00000aFibpAAC.pngI've tested the raw data that is inside the file on postman and works fine.

 

Anonymous
Not applicable

Can you add a tLogRow between your tMap and tRESTClient. This will show you what is being sent to the tRESTClient. I presume that the tFileInputRaw is set to "Read the file as a string".

 

The one component we have not looked at yet is the tRESTClient. Can you show me how that is configured?

rubenfasilva
Contributor
Contributor
Author

Hello.

yes, tFileInputraw is set to read as string.

trestclient:

 

0695b00000aFjDsAAK.png 

 

0695b00000aFjEbAAK.pngAnd with the the tlogrow between tmap and trestclient we have this:

 

0695b00000aFjH1AAK.pngLet me know if you need anything else.

Once again, thank you

Anonymous
Not applicable

OK, everything is looking OK from what I can see. Do you have any documentation for the API that I can look at? The number of records that were included in the JSON file are quite a lot. I suspect that the error message is misleading. Can you test this by reducing the number of records to 1, then try 2, 3, 4, etc, and see what you get?