API Update Ticket - Powershell

Currently I am trying write the rest of my script to update a ticket using the API.

I am trying to 'POST' a ticket update, changing the Status of ticket to In Process, and Add a comment.

Here is the snippet that is coming up with errors:

 

I keep getting an error mentioning "Invoke-RestMethod : {"ID":-1,"Message":"Comments must be provided."}".

Previous attempts were passing 'GET'($arg2 of the function) object to the $updateTickets "Body" along with my $itemUpdate. But has only provided the same error.

Any idea what needs to be changed?

 

Thanks!

 

[UPDATE 4/28/22]

I changed how my code is formatted and it works now. Here is the corrected snippet.

Tags API webapi ticket-api TeamDynamixApi
Asked by Javier Moni on Wed 4/27/22 2:48 PM Last edited Thu 4/28/22 2:25 PM
Sign In to leave feedback or contribute an answer

Answers (3)

This answer has been marked as the accepted answer
Mark Sayers Wed 4/27/22 4:01 PM

Hello Javier,

What endpoint specifically are you attempting to call?

Also, I'm not sure if it's a requirement of the language you're using or not, but a JSON object doesn't require every property and its value to be surrounded by two sets of double quotes. It really only needs a single set of double quotes.

No feedback
Sorry I'm very fresh on this side of things.
I believe you're referring to this endpoint "/api/{appId}/tickets/{id}/feed"?

But as I was writing this I re-wrote the JSON object I was trying to POST in a more tidy matter for Powershell. My issue was partly the formatting but I kept attemtpting to pass an "itemUpdate" object in the Body. I will be updating the question with a corrected snippet.

Thank you for the quick response Mark!
- Javier Moni Thu 4/28/22 2:22 PM

Bryan Weist Thu 10/13/22 4:08 PM

PATCH https://YourTDXLink.com/TDWebApi/api/{appId}/tickets/{id}?notifyNewResponsible={notifyNewResponsible}

 

Just use patch.  that way you only have to provide the fields you want to change, instead of POST where you have to provide everything.

No feedback

OU ITSM Team Thu 10/13/22 3:52 PM

The end goal here is to update the status of a ticket correct?

No feedback