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!
Answer (1)
Hi Brandon,
What is the body of the PATCH call you're trying to send exactly?
Sincerely,
Mark Sayers
Sr Support Consultant, CS
"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
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
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
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