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.

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!

Anonymous
Not applicable

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.....

 

0695b00000aFm6wAAC.pngI'll give screenshots of the config of each component other than the tRESTClient, as this should not need to change.

 

0695b00000aFmADAA0.pngThis will return each sub section of the JSON.

 

0695b00000aFmBVAA0.pngThis tJavaFlex will group the subsections into groups of 200. Just change the IF condition to alter this to a larger or a smaller grouping.

 

0695b00000aFmCxAAK.pngThis 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.

 

0695b00000aFmEyAAK.pngThe 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.

rubenfasilva
Contributor
Contributor
Author

Thank you so much for your help

You are the best!

Anonymous
Not applicable

You're welcome. I hope it works.