Building JSON POST Request(With array of child objects ) using Json Call from multiple input files

Hello,

I’m new to this product. Is it feasible to build a json request with child array objects using Json Call Step from input files? I appreciate if anyone could share some thoughts or guidance. Thanks.

Hello Ranjith,

It is certainly possible to do so. We have a very detailed Tutorial which I would recommend you to review under DQ Project -> Tutorials -> 12 Call Services -> 12.02 Json Call.plan. It summarizes how you can build a JSON POST request with child arrays using the JSON Call Step and how to parse the response afterwards. Also you can review the built-in documentation, which you can access by opening the JSON Call Step’s properties and clicking the little question mark in the bottom left corner.

Best Regards,
Alex Georgiev

Thanks Alex.
Case1: one POST call for collection of request objects
I was able to build a json file with child array objects using json writer and then reading that file as string into the Json call Input template to send the POST request contains multiple object with child array objects with one call.

Case2: I was able to build a json without child array objects using Json Call input template dynamically by reading from a file.

Case 3: multiple POST call for each input request object
Currently, trying to build json with child array objects using JSON Call dynamically .Is there a Step that i can use to build child array objects for a json input template in Json Call step dynamically ?Please advise. Thanks

Hello Ranjitn,

If I understood you correctly, your goal is to pass the child array objects for the JSON input template outside of the JSON Call step. For such case you would have to develop a new component (.comp) file instead of a plan. This way around you would be able to right click on the text where it says input template in the JSON call and map it as a parameter. Make sure you also name the parameter with the name of the respective column of your preceding data flow from which you would like to pass the input.

Best Regards,
Alex

Thanks Alex for your response. After some investigation, I got stuck with mapping a child collection objects to their parent object using column binding(similar to configuration in Json writer).

Test Case: Json one below is what I am trying to build from two input files “Parent” and “Child” joined by an "ID "for the Json call step

Json Request: Parent with collection of child objects.

{
“field 1”: “”,
“field 2”: “”,
“Children”:[
{
“field3”: “”,
“field4”: “”
}
{
“field3”: “”,
“field4”: “”
}

 ]

}

I was able to generate a json file with the above structure using the Json writer from multiple input files where i can configure the join keys etc.

But, with the case of Json Call. Should I use Json Parser or any other steps to configure the join keys to handle collections in my json request template…before sending it to the Json Call ?

I have learnt a lot in the last few days… thanks again Alex

Hi Ranjith,

I am glad to hear that you are expanding your knowledge of our product and you find my comments helpful.

There is no need to use a particular step before the JSON call such as JSON Parser. I will try to give you a simple example using a Text File Reader, although the same can be achieved with any step that would include the Input Template for the JSON Call in a certain column. Let us imagine that I have a file with the name “test.txt” that stores the string I would like to use as Input Template in my JSON Call in a column named “example”. After you drop the following file in the canvas so it can read the data from it you can add the JSON Call right after it and instead of writing the Input template in the JSON Call you can simply write #example#. This way the JSON Call step would take the template from the example column that is already in the data flow before it. Moreover, in case the hashtag (#) is not a convenient symbol for you to use in order to mark the begging and end of your template you can navigate under “Advanced” in the JSON Call step where you can change the default symbols to enclose your template (column name).

Best Regards,
Alex

1 Like

Thanks again for the reply. this is what I’m currently doing with a single object. It work fine !!! The case I stuck is where I have collections

for example: root object (Person)has more than one address (one-to-many)

File 1: Has the PErson Information
File 2: Has multiple addresses for a Person join by an ID.
Output: json request for PErson with multiple Address child objects

How I configure column binding for PArent and child objects in JSON Call?
Similar to JSON Writer where I configure column binding. It works perfect!!

Any thoughts ? Thanks again for taking time to explain the stuff in Detail :slight_smile:

Ranjith

Hi Ranjith,

Thank you for further clarifying the details for me, so I can better understand your use-case. Unfortunately, as of now JSON Call does not support functionality of parsing arrays containing just values in a fashion similar to what you have described. However, this feature is on our roadmap and would be implemented in the near feature.

Best Regards,
Alex