Open DavidHummingbird opened 1 month ago
My current workaround is to create the ticket with the CC_Email, and then use Set-FreshServiceTicket to add the attachment immediately after.
This has to due with how powershell handles JSON depths. I ran into this earlier when trying to modified a large amount of agents role permissions. THis article should explain a bit about it. But by default it only goes to a depth of 2 and it needs to be longer to turn those arrays into json arrays. https://jeffbrown.tech/going-deep-converting-powershell-objects-to-json/
But try to go into your new-freshserviceticket.ps1 file and replace the lines
$params.Body = $jsonBody | ConvertTo-Json
with
$params.Body = $jsonBody | ConvertTo-Json -depth 5
Expected Behavior
Current Behavior
Possible Solution
The issue is in
Public/New-FreshserviceTicket.ps1
(and may exist in other modules). The problem is using BOTH CC_Emails and Attachments -- when you use Attachments, the$jsonBody
is assigned to$params.form
but not converted to JSON. The.form
method accepts an IDictionary Invoke-WebRequest but the content of arrays (such as CC_Emails) is not expanded - it's represented by its object type descriptor:Inserting some debug code on line 475 of
New-FreshServiceTicket
:... produces this result:
Steps to Reproduce (for bugs)
(see code sample above)
Context
In my use case, I'm pulling a photo out of an HR system and sending it to FreshService to create a ticket for review. My requester is my service account, and I want to CC the employee (owner of the photo) on the original ticket, so they get the description. If I make the employee the requester, then they won't get the description of the ticket, just the notification that a ticket was created on their behalf.
Your Environment