Solved

How can I add a private note to a ticket using PowerShell

  • 18 April 2023
  • 6 replies
  • 154 views

Badge +1

I am trying to use PowerShell to add a private note to a ticket, I don't want it to be a plublic note as it might confuse the users. Any ideas?

icon

Best answer by ColePatterson20 19 April 2023, 19:19

View original

6 replies

Badge +1

Did you set the below:

"private":true

https://api.freshservice.com/#create_a_note

Badge +1

How would I do that in PowerShell as I am pretty new to this.

Badge +1

This command is not working after filling in the details with the user email or API key. I have also confirmed the URL is correct.

curl -v -u user@yourcompany.com:test -H "Content-Type: application/json" -X POST -d '{ "body":"Hi tom, Still Angry", "private":false }' 'https://domain.freshservice.com/api/v2/tickets/265/notes'


Note: Unnecessary use of -X or --request, POST is already inferred.
* Closing connection -1
curl: (3) URL using bad/illegal format or missing URL
Note: Unnecessary use of -X or --request, POST is already inferred.
* Could not resolve host: Still
* Closing connection 0
curl: (6) Could not resolve host: Still
curl: (3) unmatched close brace/bracket in URL position 22:
Angry, private:false }

Badge +1

Figured it out

curl.exe -v -u "%API KEY%:." -F 'body=Details about the issue...' -X POST 'https://domainname.come/api/v2/tickets/ticketnumber/notes'
 

Badge +1

$Body = @{body = "test"}

$credPair = "%APIKEY%:."
$encodedCredentials = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($credPair))
$headers = @{ Authorization = "Basic $encodedCredentials" }
Invoke-WebRequest "https://%Domain-name.com%/api/v2/tickets/%TICKET-NO%/notes" -Headers $headers  -ContentType "application/json" -Method Post -Body ($Body | ConvertTo-JSON) -UseBasicParsing

Userlevel 7
Badge +16

Hi @ColePatterson20 good work getting this work correctly. Can be tricky when first starting out.

Reply