Trying to run an api patch on a ticket type for a batch of tickets.

Hello All,
I am trying to update just the ticket type for a batch of tickets. My script is created in powershell and is using the patch method to try and update that field in a ticket. Everytime I run my code it gives me the following error message:

{"ID":-1,"Message":"patch must not be null. Errors:\r\n* Exception Message: The JsonPatchDocument was malformed and could not be parsed."}
 

I have tried 3 different formattings for the required data needed for the patch yet nothing I do works and always lead back to this error.

If anyone has any examples of how they even used a patch in TDX that could help me solve my issue.

Thank you in advance!

Tags patch-script PowerShell PATCH
Asked by Brandon Ferrotta on Wed 6/7/23 9:51 AM
Sign In to leave feedback or contribute an answer

Answer (1)

This answer has been marked as the accepted answer
Mark Sayers Wed 6/7/23 10:06 AM

Hi Brandon,

What is the body of the PATCH call you're trying to send exactly?

Sincerely,
Mark Sayers
Sr Support Consultant, CS

No feedback
$patchData = @{
"TypeID" = "39771"
"Title" = "The following selections indicate the assistance provided on this ticket:"
"AccountID" = "103117"
"StatusID" = "128627"
"PriorityID" = "6260"
"RequestorUid" = $myUid

}
- Brandon Ferrotta Wed 6/7/23 10:08 AM
If you're calling the ticket PATCH endpoint to edit these tickets one by one, that would not be the correct format for the body of a PATCH call.

Are you trying to change *all* of those pieces of data on these tickets too?

In general you should format a PATCH body like it is documented in this page: https://canton.teamdynamix.com/TDWebApi/Home/AboutPatching

You will have an array and then separate patch objects for each individual property on the ticket that you are trying to modify/add/remove.
- Mark Sayers Wed 6/7/23 10:41 AM
At the end of the day I would like to batch it, I was testing just for one at a time.

I don't need all the fields (saw it was required on the documentations so just added them just incase)

I created this patch format and even tried running it in postman and in powershell and I get the same error message as before:
{
"op": "replace", "Path": "/TypeID", "value": "39771"
}
- Brandon Ferrotta Wed 6/7/23 11:04 AM
We don't have a PATCH endpoint that allows for modifying a group of tickets in this way. You can write your script to iterate through a list of ticket IDs though to patch them one by one, that will be the only way to do this for sure in an automated fashion. Did you place that inside an array though? The [ and ] characters? - Mark Sayers Wed 6/7/23 11:09 AM
Hi Mark,

Thank you so much for your input and help. I was not adding it into the [ ] in postman but once I did it worked. Finally was able to get it working in powershell as well had to add it to a powershell array and then encase all that inside "...."

Yes I had already created the script to iterate over a list, just wanted to test it on a single instance before I tried to mass run it in SB haha.

Everything is working as expected now! Thanks again
- Brandon Ferrotta Wed 6/7/23 12:34 PM