Attachment API to upload a file to a catalog item getting invalid extension

Craig Hook
Tera Contributor

When using something like below this I am getting invalid extension even though the extensions property has the extension I am using.

# Set proper headers
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add('Authorization',('Basic {0}' -f $base64AuthInfo))
$headers.Add('Accept','*/*')
$headers.Add('Content-Type','image/png')


$attachUri = "https://$instancename/api/now/attachment/file?table_name=sc_cat_item&table_sys_id=" + $id + "&file_name=picture"

$upload= Invoke-RestMethod -Headers $headers -Uri $attachUri -Method Post -InFile "f:\Program Files (x86)\Flexera Software\App Portal\Web\Images\Packages\Objects.png" -ContentType 'image/png'

 

When I use file_name=picture.png it uploads the attachment but it doesn't associate it with the picture field in the catalog item.    I noticed when using the ui and I add a picture in the picture field it also creates row in the sys_attachment table but the file name doesn't include *.png.    

0 REPLIES 0