Skip to main content
Solved

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


ColePatterson20
Top Contributor
Forum|alt.badge.img+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?

Best answer by ColePatterson20

$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

View original
Did this topic help you find an answer to your question?

6 replies

Forum|alt.badge.img+1

Did you set the below:

"private":true

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


ColePatterson20
Top Contributor
Forum|alt.badge.img+1

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


ColePatterson20
Top Contributor
Forum|alt.badge.img+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 }


ColePatterson20
Top Contributor
Forum|alt.badge.img+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'
 


ColePatterson20
Top Contributor
Forum|alt.badge.img+1
  • Author
  • Top Contributor
  • 5 replies
  • Answer
  • April 19, 2023

$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


zachary.king
Skilled Expert
Forum|alt.badge.img+16
  • Skilled Expert
  • 951 replies
  • April 20, 2023

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


Reply