You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$params = @{
status = $fsStatus
priority = $fsPriority
urgency = $fsUrgency
impact = $fsImpact
source = $fsSource
email = $fsRequester
subject = $fsSubject
type = "Incident"
category = $fsCategory
cc_emails = @($cc_email)
description = $body
attachments = @($(New-Object System.IO.FileInfo -ArgumentList $file))
}
$fsTicket = New-FreshServiceTicket @params
{"description": "Validation failed", "errors": [ {"field": "cc_emails", "message": "The value provided is of type String.It should be of type Array", "code": "datatype_mismatch" }] }
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:
[category, IT Operations]
[priority, 1]
[urgency, 2]
[status, 4]
[impact, 1]
[type, Incident]
[email, no-reply@company.com]
[subject, Microsoft Photo Change Review: David]
[attachments[], System.IO.FileInfo[]]
[source, 2]
[description, <p><b>David</b> changed their photo recently in Workday and we're syncing it to Microsoft.<br/>]
[cc_emails, System.String[]]
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
Module version used: 0.1.6
Operating System and PowerShell version: Azure Automation, Powershell 7.2
The text was updated successfully, but these errors were encountered:
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
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
The text was updated successfully, but these errors were encountered: