我正在使用REST API将附件推入ServiceNow。我在文件夹结构中有附件,例如事件→编号→附件。我正在使用下面的代码,但它给我一个错误,提示404格式问题。
$headers2 = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers2.Add('Authorization', ('Basic {0}' -f $base64AuthInfo))
$headers2.Add('Accept', 'application/json')
$headers2.Add('Content-Type', $mime)
$allFileBytes = [System.IO.File]::ReadAllBytes($filePath)
$Fields = @{'uploadFile' = $allFileBytes};
$instance = "https://devXXXX.service-now.com"
$table = "incident"
$uri2 = "https://devXXXX.service-now.com/api/now/attachment/file?table_name=" +
$table + "&table_sys_id=" + $Sys_Id + "&file_name=" + $filename
$data2 = Invoke-RestMethod -Headers $headers2 -Method Post -Uri $uri2 -Body $Fields
$Insert_Sys_ID = ''
$Insert_Sys_ID = $data2.result.sys_id