This discussion has been locked. The information referenced herein may be inaccurate due to age, software updates, or external references.
You can no longer post new replies to this discussion. If you have a similar question you can start a new discussion in this forum.

Add Tech Notes via PowerShell (Invoke-RestMethod)

Hi All,


I’m doing some testing with PowerShell’s Invoke-RestMethod & WHD rest api around creating tech notes for pre-existing tickets & am having no luck. When I run the bellow script, I receive the following error: Invoke-RestMethod : This operation is not permitted due to invalid Subscriber ID. The Subscriber of the JobTicket entity has to match the current users's Subscriber.

Script:-

$test = @{
noteText= "Test"
jobticket= @{
Type="JobTicket"
ID="11678"
}
worktime="1"
isHidden="false"
isSolution="false"
statusTypeId= "1"
emailClient= "false"
emailTech= "false"
emailTechGroupLevel= "false"
emailGroupManager= "false"
emailCc= "false"
emailBcc= "false"
ccAddressesForTech= "false"
bccAddresses=""
}


$json = $test | ConvertTo-Json

Invoke-RestMethod whd/.../TechNotes -Method POST -Body $json -ContentType "application/json" -Verbose

I'm assuming I am doing something wrong, can anyone point me in the right direction?

Message was edited by: Brad Cope Grammar

  • Hey there, just wondering if you ever found a fix for this. I'm trying to create new tickets using REST API and getting the same error.  Pretty standard installation, nothing out of the ordinary, GET requests work without issue.  I'm creating the JSON body the same way as you with just the mandatory "problemtype" field and a description.  Then running:

    Invoke-RestMethod 'https://servicedesk/helpdesk/WebObjects/Helpdesk.woa/ra/Tickets?username=admin&apiKey=APIkey' -Method POST -Body $json -ContentType "application/json" -Verbose

    I can't find a reference to a subscriber ID in any of the documentation so I think I might open a job with support...

  • I also ran into this when trying to create tickets via REST.  The error showed up when I tried to use a "username" field to identify a client instead of "id".  It also got picky about the case of the "id" parameter and it didn't like strings getting passed to numeric fields, ie. "id":"12015" vs. "id":12015

    Here's an example of a JSON object that creates a ticket successfully for me:

    {

         "subject":"test",

         "detail":"testing",

         "problemtype":{

              "type":"ProblemType",

              "id":1

         },

         "location":{

              "type":"Location",

              "id":10

         },

         "clientReporter":{

              "type":"Client",

              "id":"ehussey"

         },

         "statustype":{

              "type":"StatusType",

              "id":1

         },

         "prioritytype":{

              "type":"PriorityType",

              "id":4

         }

    }