Hello,
I'm trying to send data through a JSON Body, however I think that the API receiving the data is expecting a nested JSON, with the text "inputs" in the first level, and the inputs themselves in the second level:
More details: https://developer.salesforce.com/docs/atlas.en-us.api_action.meta/api_action/actions_obj_custom_notification.htm
So in EasyMorph, I created the following action:
However, here I can't include the first JSON level ("inputs"). At the moment this is an "Iterate Web Request" action because I was planning to use some of the columns as the values to send.
Do I need to construct this JSON structure through other actions first and then either select the column where the JSON is (Body is "Column"), or save the JSON created in a file and then upload that (Body is "File")?
EDIT: Another option I've been thinking about would be, instead of constructing the JSON, just create a new column where I have the literal JSON in text and I substitute the values I want to fill out with parameters / other column values, and concatenating everything. For example:
'"{ "inputs" :
[
{
"customNotifTypeId" : '&[column1]&',
"recipientIds" : ['&{parameter1}&'],
"title" : "Custom Notification",
"body" : "This is a custom notification.",
"targetId" : "'&{parameter2}&'"
}
]
}'
And then I select this column as the one containing the JSON Body. What do you think?
Thanks very much,
Roberto
There are 2 options here:
The “JSON body” mode of the “Web request” action allows values to be JSON objects. If the action detects that a text value is a JSON, it inserts it as nested JSON, not as text. So you can build simple JSON objects with 1-2 levels of hierarchy.
Alternatively, use the “Construct JSON” action. It allows building JSON objects of any complexity. The web-help article contains links to examples.
So for my example, what I did was the following:
Now I have one key "inputs" and the "Value" is a calculated parameter "Notification settings" with the following expression, which builds the JSON array (here I have concatenated a parameter into the JSON array):

Now I've done the POST request and it is working. Is this what you are referring to?
Thanks!
Great, thanks! I have modified my previous post, I placed an example where the value is a calculated parameter, where the array gets built.
Hello,
I have another requirement that involves having one of the values in the object, a string that holds a JSON (I have to send it literally, as a string wrapped in quotes):
Having added this, EasyMorph is no longer interpreting this value as a JSON, because it starts showing \r and \n in the request:
Is there a way where I can include this JSON string into the Value, and that EasyMorph stills interprets it all as a JSON?
Thanks very much,
Roberto
For complicated cases, use the “Construct JSON” action.