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

Update custom fields issue #5

Closed
DragonZelda opened this issue Jan 14, 2013 · 5 comments
Closed

Update custom fields issue #5

DragonZelda opened this issue Jan 14, 2013 · 5 comments

Comments

@DragonZelda
Copy link

Hi,

When I update the custom fields or attach files, the following error will occur:
Error reading string. Unexpected token: StartArray. Path 'audit.events[0].previous_value', line 1, position 1489.

After checking, this problem occur because the audit event return previous_value in array format, for example:

{"id":10323257041,"type":"Change","value":["cherry_credits_account_issues","deleted"],"field_name":"tags","previous_value":["cherry_credits_account_issues","pending"]},

If first time attach file, previous_value will become:
"previous_value":[]

Please advice what should I do to handle this problem.
Thank you very much.

Regards,
Khaw How Cheng

@eneifert
Copy link
Contributor

Hi Khaw How Cheng,

If you are talking about updating a ticket field itself, unfortunately that has never worked and the problem is with the api itself (not the c# interface). I believe that I submitted a bug a while back, but I can submit it again. If you are talking about merely setting an existing field, then I will need you to provide me with more information, as I have tested this and can not see any problems.

Also I'm not really sure I follow the error you are explaining. If it is reproducible, can you tell me what steps you did to see the error?

Also sorry to be repetitive but since I am able to use the api to upload files just fine I will need more information on how to reproduce that problem as well.

Hopefully we'll get it figured out,
Eric

@DragonZelda
Copy link
Author

What I mean is update the custom_fields and it always work.
The problem is the C# interface cannot handle the return value.

Kindly please go to here:
http://developer.zendesk.com/documentation/rest_api/ticket_audits.html#audit-events

Search for "Ticket Change Events" -> "previous_value"
The Previous Value type is string / array.
But in your library, Models -> Shared -> Event.cs the previous value code is as following:

    /// <summary>
    /// Used when event is Change
    /// </summary>
    [JsonProperty("previous_value")]
    public string PreviousValue { get; set; }

Which means that audit event only accept string value.
So if any return previous value variable is in array format, error will occur as:

    Error reading string. Unexpected token: StartArray. Path 'audit.events[0].previous_value', line 1, position 1489.

The following is the sample. I update the tickets comments and custom fields, then the following code return:

"{"ticket":{"url":"https://cherrycredits.zendesk.com/api/v2/tickets/23046.json","id":23046,"external_id":null,"via":{"channel":"api","source":{"from":{},"to":{},"rel":null}},"created_at":"2013-01-15T03:13:46Z","updated_at":"2013-01-15T03:14:53Z","type":null,"subject":"Zendesk Testing Ticket Update Test","description":"Testing 123 ","priority":"normal","status":"solved","recipient":null,"requester_id":237396317,"submitter_id":237396317,"assignee_id":null,"organization_id":null,"group_id":null,"collaborator_ids":[],"forum_topic_id":null,"problem_id":null,"has_incidents":false,"due_at":null,"tags":["cherry_credits_account_issues","deleted"],"custom_fields":[{"id":21437213,"value":"deleted"},{"id":21437063,"value":"0"},{"id":21147097,"value":"T1207181814871J"},{"id":21123312,"value":"cherry_credits_account_issues"}],"satisfaction_rating":null,"sharing_agreement_ids":[],"fields":[{"id":21437213,"value":"deleted"},{"id":21437063,"value":"0"},{"id":21147097,"value":"T1207181814871J"},{"id":21123312,"value":"cherry_credits_account_issues"}]},"audit":{"id":10349790161,"ticket_id":23046,"created_at":"2013-01-15T03:14:53Z","author_id":245504337,"via":{"channel":"api","source":{"from":{},"to":{},"rel":null}},"metadata":{"system":{"ip_address":"116.12.134.130","location":"Singapore, 00, Singapore","latitude":1.2931000000000097,"longitude":103.85579999999999},"custom":{}},"events":[{"id":10349790171,"type":"Comment","author_id":245504337,"body":"This ticket is deleted by user.","html_body":"

This ticket is deleted by user.

","public":false,"trusted":true,"attachments":[]},{"id":10349790181,"type":"Change","value":["cherry_credits_account_issues","deleted"],"field_name":"tags","previous_value":["cherry_credits_account_issues","pending"]},{"id":10349790191,"type":"Change","value":"deleted","field_name":"21437213","previous_value":"pending"},{"id":10349790201,"type":"Change","via":{"channel":"rule","source":{"to":{},"from":{"id":30262543,"title":"User or Agent deletes ticket"},"rel":"trigger"}},"value":"solved","field_name":"status","previous_value":"new"}]}}"

In the return string, the following variable:
"previous_value":["cherry_credits_account_issues","pending"]}

cannot be accepted by the C# interface because it only handle string value.
Following error will occur:

    Error reading string. Unexpected token: StartArray. Path 'audit.events[1].previous_value', line 1, position 1713.

Regards,
How Cheng

@eneifert
Copy link
Contributor

Hmm, I did exactly what you did but was unable to reproduce the error. However I changed the PreviousValue field to be of type object. So hopefully that will fix your problem.

@DragonZelda
Copy link
Author

Thank you very much. The issue solve.

@eneifert
Copy link
Contributor

Thanks for reporting the problem!

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

No branches or pull requests

2 participants