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.
Answers (3)
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.
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
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.
The end goal here is to update the status of a ticket correct?