Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistant 422 Errors Unprocessable Entity - Updating Trigger #226

Closed
Alin-Dumitrescu opened this issue Jun 15, 2016 · 6 comments
Closed

Comments

@Alin-Dumitrescu
Copy link

Hello,

I have some simple code that intends to enable an existing disabled trigger. here is the code and the error:
IndividualTriggerResponse z = zenApi.Triggers.GetTriggerById(triggerId);
z.Trigger.Active = true;
zenApi.Triggers.UpdateTrigger(zenTriggerResponse.Trigger);

The error:
System.Net.WebException was unhandled
HResult=-2146233079
Message=The remote server returned an error: (422) Unprocessable Entity.Error content: {"error":"RecordInvalid","description":"Record validation errors","details":{"base":[{"description":"Invalid value 'web' in 'Update via / Is not / web'"}]}}

The trigger has a condition: Is Not updated via web Form. Somehow that makes the update unhappy. If i remove that condition, the update works.

{
"field": "current_via_id",
"operator": "is_not",
"value": "web"
},

@mozts2005 mozts2005 added this to the 4.0.0 milestone Jul 13, 2016
@mozts2005
Copy link
Member

Can you submit a test case that has this issue? I understand that sometimes the test will pass and sometimes it will fail.

@Alin-Dumitrescu
Copy link
Author

Alin-Dumitrescu commented Jul 13, 2016

The code I put in there is 100 reproable all the time. The issue is that zendesk expects an id (eg 5) for the update method. When you get the entity, it has the value (API). So, a get, followed by update the trigger object to enable/disable ,followed by an update will fail all the time.

Thank you,
Alin

@mozts2005
Copy link
Member

Would you please create a test with the full workflow and submit it as a pull request and we will see about getting the issue fixed.

@Tyf0x
Copy link
Contributor

Tyf0x commented Aug 25, 2016

# THE CAUSE

I had a look into this and can confirm a bug (probably on zendesk side).

The trigger condition "Update Via" in the web UI corresponds to the "current_via_id" API field which expects an ID value corresponding to a via type.

The problem is that when retrieving the trigger, zendesk API sends:

"any" : [{
    "field" : "current_via_id",
    "operator" : "is_not",
    "value" : "web"
  }
]

which is the name value instead of the ID.

This makes the API spit an error when trying to update the Trigger on the next update.

# TEST CODE

  1. Trigger creation:

image

  1. Test code
  var myTrig = _zendeskApi.Triggers.GetTriggerById(<<insert_trigger_id>>).Trigger;
  myTrig.Active = true;
  _zendeskApi.Triggers.UpdateTrigger(myTrig);

@Tyf0x
Copy link
Contributor

Tyf0x commented Sep 1, 2016

Submitted a ticket to zendesk support and waiting for an answer.

@mozts2005
Copy link
Member

Given that this is zendesk issue and the support ticket has been opened with them. I am closing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants