Solved

Saving JSON response to attribute as JSON

  • 11 December 2022
  • 2 replies
  • 77 views

From an API request we get the response:

{
  "records": [
    {
      "id": "recJFKtwINHpI2vAO",
      "createdTime": "2022-12-09T21:30:57.000Z",
      "fields": {
        "id": "4dd9cb87-3571-4fd4-8298-c7bf6e11cb1d",
        "propertyName": "property A",
      }
    },
etc
]
}

When trying to set `testJson` to `{{response.records[0]}}` to an attribute, it comes with these arrow type expressions, which aren’t accessible by customer.testJson[“fields”] or customer.testJson.fields etc.

{“createdTime”=>“2022-12-09T21:30:57.000Z”, “fields”=>{“id”=>“4dd9cb87-3571-4fd4-8298-c7bf6e11cb1d”, “propertyName”=>“property A”}, “id”=>“recJFKtwINHpI2vAO”}

 

I’d like to set the entire response as the testJson, but 1 thing at a time.

I couldn’t find a liquid function to preserve the json.

icon

Best answer by matt 11 December 2022, 02:36

View original

2 replies

Solved

https://customer.io/docs/webhook-triggered-campaigns/

Need to use `| to_json` . I had tried tojson and json

Glad you found a workaround here, Matt! Thanks for sharing that.

Reply