Hello.
I am making calls with an integration to an external system and I am unable to use Appian's built-in JSON formatter to do so. As far as I have read on the documentation, I am also unable to do the type of string manipulation necessary to dynamically construct the JSON from scratch so that it is compatible. I am only able to statically send text as JSON for it to work.
Here are the bodies and results for a success and failure:
Body (Content Type: JSON):
"[ { ""startPublicationDate"": ""2021-09-05"", ""endPublicationDate"": ""2021-09-05"" } ]"
Result:
concat( "[ ", a!toJson( value: a!map( startPublicationDate: concat( text(ri!startPublicationDate, "yyyy"), "-", text(ri!startPublicationDate, "mm"), "-", text(ri!startPublicationDate, "dd") ), endPublicationdate: concat( text(ri!endPublicationDate, "yyyy"), "-", text(ri!endPublicationDate, "mm"), "-", text(ri!endPublicationDate, "dd") ) ) ), " ]" )
Again, the default Appian JSON format does not work (a!toJSON) and both bodies are validated JSON. How can I manipulate a string that contains quotes such as a JSON? If that is not possible, how else could I dynamically construct the JSON so that the external system accepts it?
Thanks.
Discussion posts and replies are publicly visible
The JSON you constructed is anyway not valid. If you try to pass it in a!fromJson, it will give you an error. Rather, use the below code snippet. I have tried to simply it also for you.
a!toJson( value: { a!map( startPublicationDate: text(ri!startPublicationDate, "yyyy-mm-dd"), endPublicationdate: text(ri!endPublicationDate, "yyyy-mm-dd") ) } )
Some information about JSON -