Skip to main content
New Participant
Jan 29, 2024 7:03 PM UTC
Solved

Default Appian JSON Format Not Compatible With External System in Integration

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:

Body (Content Type: JSON): 

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")
)
)
),
"
]"
)

Result:

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.

stefanhelzle0001
Brainy
Jan 30, 2024 6:47 AM UTC

the working code uses "endPublicationDate", while the failing code uses "endPublicationdate". Do you spot the difference?

6 replies

harshitb6843
Brainy
Jan 29, 2024 7:21 PM UTC

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")
    )
  }
)

harshitb6843
Brainy
Jan 29, 2024 7:26 PM UTC

Some information about JSON - 

  1. In JSON, square brackets represent an array. So if you want to add them, just wrap your data in {} on Appian because Appian uses {} for an array. 
  2. Appian's JSON doesn't work differently than the rest of the internet. JSONs are universally standard and you should have no problem trying to use a!toJson and a!fromJson as long as your map is correct.