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?
Hello.
You are right.
With my 14000 records json file, it will be a ver long string.
How can I generate output json files with 200 records max?
Thnk you so much!
OK, this was interesting. I have a bit of a hack to fit this into how you have built your job up to this point. It might be better to build your job differently, but this should work. The last section of your job (once you have built your stocks file) should look like this.....
I'll give screenshots of the config of each component other than the tRESTClient, as this should not need to change.
This will return each sub section of the JSON.
This tJavaFlex will group the subsections into groups of 200. Just change the IF condition to alter this to a larger or a smaller grouping.
This tAggregateRow will group your subsections into a String list by the group key. So, there will be 200 subsections output per row returned. They will be comma separated.
The final tJavaFlex will wrap the value returned by the tAggregateRow between "[" and "]". This will complete your JSON String. Notice that I am sending it to the "string" column.
You will need to make sure that your schema for the last tJavaFlex matches the schema for the tRESTClient's input schema.
I think this will work. I haven't been able to test it with your API, but have tested that it returns JSON correctly. You may need to play with the numbers in each group.
EDIT: I just noticed that the code in the last tJavaFlex is slightly wrong. This came from me testing using a tLogRow. It is the just the "row" names. They were different before I replaced the tLogRow with a tRESTClient. Just make sure your row names match what is on your job.
Thank you so much for your help
You are the best!
You're welcome. I hope it works.