What is wrong about my trigger creation request?



2023년 2월 01일에 게시됨

I am following this instruction to create a trigger by calling this endpoint:

POST https://wunderkindtest.zendesk.com/api/v2/triggers

The request body:

{
   "title":"Test trigger",
   "active":true,
   "conditions":{
     "all":[
      {
       "field":"comment_is_public",
       "value":true
       },
      {
       "field":"update_type",
       "value":"Change"
      }
   ]
   },
   "actions":[
   {
     "field":"notification_webhook",
     "value":[
         "abc",
         "123"
       ]
   }
 ]
}
 
I got the response:
{
"error": "RecordInvalid",
"description": "Record validation errors",
"details": {
"base": [
{
"description": "Invalid conditions. You must select at least one condition."
}
]
}
}
 
May I know what's wrong on my request body? How should I correct it? Thanks,
Junsheng

0

6

댓글 6개

      Thank you Jack. Yes, you are right. It works after wrapping with "trigger" node. In the meanwhile, I found a issue when creating a trigger with this condition:

              {
                  "field":"current_via_id",
                  "operator":"is",
                  "value":0
               }

      After creation, the UI shows:

      It suppose to be:

      But anyway, this condition works as expected just a UI issue I guess.

       

      Junsheng

      0


      Ah ok! 

       

      I believe the problem is that you are not including the "trigger" parameter that the request requires, try this: 

      {
      "trigger":{
      "title":"Test trigger",
      "active":true,
      "conditions":{
      "all":[
      {
      "field":"current_tags",
      "value":"wunderkind",
      "operator":"includes"
      }
      ]
      },
      "actions":[
      {
      "field":"notification_webhook",
      "value":[
      "abc",
      "123"
      ]
      }
      ]
      }
      }

      1


      Thank you for reply, but I don't think that's the reason since I tested by following json with operator in the condition, it did not work:

      {
      "title":"Test trigger",
      "active":true,
      "conditions":{
      "all":[
      {
      "field":"current_tags",
      "value":"wunderkind",
      "operator":"includes"
      }
      ]
      },
      "actions":[
      {
      "field":"notification_webhook",
      "value":[
      "abc",
      "123"
      ]
      }
      ]
      }
      From the doc, some conditions allow missing operator, e.g.
      update_type Omit the operator property "Create" or "Change"
      comment_is_public Omit the operator property true, false, "not_relevant" (present), or "requester_can_see_comment" (present and requester can see comment)
      ticket_is_public Omit the operator property "public", "private"
       

      0


      My mistake, I think maybe it’s because your conditions do not have any operators? Please see this docs page for examples on creating or updating triggers https://developer.zendesk.com/documentation/ticketing/reference-guides/conditions-reference/

      0


      It doesn't work even if I added `any`:

      "conditions":{
      "all":[
      {
      "field":"comment_is_public",
      "value":true
      },
      {
      "field":"update_type",
      "value":"Change"
      }
      ],
      "any":[]
      }

      0


      You need to also specify any conditions, you correctly have “all” conditions, I think maybe an empty array for “any” would fix this.

      0


      댓글을 남기려면 로그인하세요.

      원하는 정보를 못 찾으셨나요?

      새 게시물