Recent searches


No recent searches

Passing Null Custom Field Data to New Ticket via POST



Posted Jan 26, 2022

I have a trigger set up that his this endpoint:

  • POST /api/v2/tickets

Part of the JSON that I pass through the webhook is custom field data and I run into an error "Failed: 422 Unprocessable Entity (WebDV)" when I try to pass through custom field data that has a null value.

How do I get around this? Let for example that this is my JSON which contains null values below. Please Note: The webhook works as expected when the custom fields are filled out prior to hitting the webhook.

{
  "ticket": {
    "comment": {
    "body": "This ticket was created to help!",
      "public": false
    },
    "custom_fields": [
        {
          "id": 4415661978388,
          "value": 401187672072
        },
        {
          "id": 4415682949268, 
          "value": 246214
        },
        {
          "id": 360041327151, 
          "value": 
        },
        {
          "id": 360041372052, 
          "value": ""
        },
        {
          "id": 360041372372, 
          "value": 
        },
        {
          "id": 4417038927636, 
          "value": ""
        }
      ],
     "assignee_id": 401187672072,
     "group_id": 360011083932,
  "subject": "Test Subject",
    "requester_id": 401187672072,
    "status": "pending", 
    "tags": [
    "reporter"
      ]
  }
}

0

2

2 comments

image avatar

Sebastiaan (Sparkly ⭐)

Community Moderator

Hey Dean,

I'm not sure if it's the formatting, or that the `null` values are actually not in your payload. Maybe you could try this:

    "custom_fields": [
        {
          "id": 4415661978388,
          "value": 401187672072
        },
        {
          "id": 4415682949268, 
          "value": 246214
        },
        {
          "id": 360041327151, 
        "value": null
        },
        {
          "id": 360041372052, 
          "value": ""
        },
        {
          "id": 360041372372, 
        "value": null
        },
        {
          "id": 4417038927636, 
          "value": ""
        }
      ],

Or if that fails, try empty Strings like the other fields? Haven't tested it yet, but I never had this issue, so I guess it's one or the other 😅

0


Sebastiaan (Sparkly ⭐) I figured it out. Since this JSON is getting fired from a ZD trigger I cannot know at the time of making the trigger if the data will be null or not. I was running into a problem on integer values specifically.

I naturally did not put quotes around the {{ticket.ticket_field_id}}, but this was causing a problem when null values would populate. When I put quotes around it, then it did work. So the example would look like:

"custom_fields": [
        {
          "id": 4415661978388,
        "value": "{{ticket.ticket_field_id}}"
        }
]

0


Please sign in to leave a comment.

Didn't find what you're looking for?

New post