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

Announcements
Join us in Toronto Sept 9th 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)
1 Solution

Accepted Solutions
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?

View solution in original post

23 Replies
Anonymous
Not applicable

You'll need to explain what is happening here. Why do you have JSON going to a tXMLMap? That seems a little odd. Also, how is your original JSON formed? Is that it in the example above? How is your tFileInputJSON configured? What does your API expect in terms of structure?

Anonymous
Not applicable

Hi

Make sure the 'All in one' option is set to 'true' if you want to build one document.

0695b00000aEwG4AAK.png 

Regards

Shong

rubenfasilva
Contributor
Contributor
Author

Hello Shong.

I tried your way, buy my post api is expecting my json struture, but i am receiving this:

200||{"data":[{"status":"error","error":"SKU is a required param","erp_transaction_id":null}]}.

And this is api server logs:

 

0695b00000aFSyhAAG.pngI don't understand why

Anonymous
Not applicable

I think the best way of solving this is to work out what you are API actually needs first. Getting the job right can only be done once you know what you should be sending the API. This will depend up on the documentation for the API. Once you know what needs to be sent, we can help you get it sent in the right way with Talend.

rubenfasilva
Contributor
Contributor
Author

The api needs this structure and the json file is ok with this:

[

{

    "sku" : "A",

    "warehouse" : "NY",

    "qty" : 2

},

{

    "sku" : "B",

    "warehouse" : "CA",

    "qty" : 3

},

{

    "sku" : "C",

    "warehouse" : "LA",

    "qty" : 1

 }

]

 

I've tried this json structure on the API using postmad and works fine.

Maybe it's something between txmlmap or trestclient?

Anonymous
Not applicable

You shouldn't be using a tXMLMap for this. That is for XML, not for JSON. How are you creating this JSON?

rubenfasilva
Contributor
Contributor
Author

Hi

The json file is created like this:

0695b00000aFUDYAA4.pngWith Generate an json array option as True

 

Tmap:

0695b00000aFUIxAAO.pngIf you need more info, let know!

Thank you all!

 

 

Anonymous
Not applicable

I presume that the "stocks" file is the file you are reading with your tFileInputDelimited component. Is that correct? I also presume that you just want to send everything in the file in one API call. Is that correct?

 

If so, you can change the tFileInputDelimited to a tFileInputRaw. Output as a String. Connect that to a tMap and connect the Rest component to the output of the tMap. Connect your input "content" field to the output "string" field.

 

This will connect the content to your REST component unchanged. If you need it change, we will need to do something a little differently, but I will need to know what you want changed.

Anonymous
Not applicable

Oh, if that "stocks" file has private data in it, you should probably take it down.