Default Appian JSON Format Not Compatible With External System in Integration

Certified Senior Developer

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.

  Discussion posts and replies are publicly visible

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

  • 0
    Certified Senior Developer
    in reply to Harshit Bumb (Appyzie)

    I have tried that code before and it gives the same error as in the posted screenshot. However, creating an expression and calling it in the integration body works:

    Expression (ABC_SearchParams):

    a!localVariables(
      local!startDt: todate("05/09/2021"),
      local!jsonArray: append(
        {},
        {
          "startPublicationDate": text(local!startDt, "YYYY-MM-DD"),
          "endPublicationDate": text(local!startDt, "YYYY-MM-DD")
        }
      ),
      local!jsonArray
    )

    Integration Body (Content Body: JSON):

    rule!ABC_SearchParams()

    Result:

Reply
  • 0
    Certified Senior Developer
    in reply to Harshit Bumb (Appyzie)

    I have tried that code before and it gives the same error as in the posted screenshot. However, creating an expression and calling it in the integration body works:

    Expression (ABC_SearchParams):

    a!localVariables(
      local!startDt: todate("05/09/2021"),
      local!jsonArray: append(
        {},
        {
          "startPublicationDate": text(local!startDt, "YYYY-MM-DD"),
          "endPublicationDate": text(local!startDt, "YYYY-MM-DD")
        }
      ),
      local!jsonArray
    )

    Integration Body (Content Body: JSON):

    rule!ABC_SearchParams()

    Result:

Children