Workflow HTTP request body parsing error

Workflows now supports using objects and arrays in inline variables! To force objects and arrays to resolve to JSON instead of Golang strings, add a .JSON() to the end of your JSONpath. For example, $.trigger.identity is an object, and $.trigger.changes is an array. Adding .JSON() to each will make them print out their JSON representation instead of Golang representation.

{
  "identity": {{$.trigger.identity.JSON()}},
  "changes":{{$.trigger.changes.JSON()}}
}

Becomes this:

{
  "changes": [
    {
      "attribute": "department",
      "newValue": "marketing",
      "oldValue": "sales"
    },
    {
      "attribute": "manager",
      "newValue": {
        "id": "ee769173319b41d19ccec6c235423236c",
        "name": "ed.engineer",
        "type": "IDENTITY"
      },
      "oldValue": {
        "id": "ee769173319b41d19ccec6c235423237b",
        "name": "william.wilson",
        "type": "IDENTITY"
      }
    },
    {
      "attribute": "email",
      "newValue": "[email protected]",
      "oldValue": "[email protected]"
    }
  ],
  "identity": {
    "id": "ee769173319b41d19ccec6cea52f237b",
    "name": "john.doe",
    "type": "IDENTITY"
  }
}

Numbers, strings, and booleans do not need .JSON().

1 Like