Closed JasonDTX closed 1 year ago
Hiya, Not sure if Add-ServiceNowAttachment is supposed to do multiple files.
If it is, I think the Content-Type header might be duplicated in the ForEach loop here:
https://github.com/Snow-Shell/servicenow-powershell/blob/19e38411ee978aff2581eb06f5cdb2827042a289/ServiceNow/Public/Add-ServiceNowAttachment.ps1#L173
I think with multi-file you'll want the type to be multipart or octet-stream. Haven't tried fixing it yet, currently just working around by sending one file at a time.
Operating System: Windows Powershell ServiceNow module version: 3.4.1 PowerShell version: 5.1
Use a splat containing two filepath
$addServiceNowAttachmentSplat = @{ ID = $Ticket.Number Table = 'incident' File = $LogFilePath, $OutputFilePath } Add-ServiceNowAttachment @addServiceNowAttachmentSplat
Multiple files upload to service now incident
First item is uploaded, next files generate error "Item has already been added. Key in dictionary: 'Content-Type' Key being added: 'Content-Type'"
Thanks for reporting this @JasonDTX. Would you mind testing the fix #208?
Looks good, posting in 208, closing 207.
Hiya, Not sure if Add-ServiceNowAttachment is supposed to do multiple files.
If it is, I think the Content-Type header might be duplicated in the ForEach loop here:
https://github.com/Snow-Shell/servicenow-powershell/blob/19e38411ee978aff2581eb06f5cdb2827042a289/ServiceNow/Public/Add-ServiceNowAttachment.ps1#L173
I think with multi-file you'll want the type to be multipart or octet-stream. Haven't tried fixing it yet, currently just working around by sending one file at a time.
Environment
Steps to reproduce
Use a splat containing two filepath
Expected behavior
Multiple files upload to service now incident
Actual behavior
First item is uploaded, next files generate error "Item has already been added. Key in dictionary: 'Content-Type' Key being added: 'Content-Type'"
Screenshots