So I have a Json structure in which there are 2 fixed text fields and 2 json objects . Inside the json objects I have dynamic attributes or parameters . Below is the example of the json
[ { "resource": "NALA",
"destination":
{ "url": "www.test.com" },
"destinationType": "testdest",
"parameters": { "division": "", "SAPSalesOrg": "4640", "salesOffice": "", "salesGroup": "", "distributionChannel": "" }
} ]
Now in this example the destination and the Parameters are json objects in which they have dynamic parameters and there is no fixed structure for it . How can I pass these dynamic parameters to a REST API in a POST method. It would be great if you can provide an end to end solution with detailed steps
Hello,
Here's a very good article on how to work with dynamic JSON attributes in OutSystems. Take a look and see if it helps you:
https://medium.com/@jsmarques13/integrating-dynamic-structures-with-outsystems-6c45e36a4d47
Thanks Aurelio for replying . Will try this out and will let you know.
Regardless of whether the specific solution described in that article matches what you need, the OnAfterResponse is the way to go for handling dynamic JSON.
@Aurelio Junior I am facing 2 issues while using this approach suggested by you in the article.
1) The JSON objectify is not converting my data from key value to object in the Onbefore Request
2) I am already using OnbeforeRequestAdvanced for my API call as I have the Add client certificate server action in it to adda certificate. I guess the Add client certificate server action can only be used in OnbeforeRequestAdvanced and not in OnbeforeRequest as it throws error of Object not set to reference
The 1st point is resolved.
Only 2nd Point is yet to be resolved. It would be great if you can help me with the below 2nd issue ; .
Yeah, I guess that makes it a bit harder. If you use the OnBeforeRequestAdvanced, you might need to do the conversion of the JSON in the extension. I never tried to combine it with manipulation both in the extension and in the module, so I can't guide you there.
Thanks Killian for your reply.
You're welcome, sorry I couldn't be of more help.