Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
Is possible to make one request only?
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?
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?
Hi
Make sure the 'All in one' option is set to 'true' if you want to build one document.
Regards
Shong
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:
I don't understand why
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.
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?
You shouldn't be using a tXMLMap for this. That is for XML, not for JSON. How are you creating this JSON?
Hi
The json file is created like this:
With Generate an json array option as True
Tmap:
If you need more info, let know!
Thank you all!
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.
Oh, if that "stocks" file has private data in it, you should probably take it down.