cancel
Showing results for 
Search instead for 
Did you mean: 

ServiceNOW Upload Attachment

PavelKrál
Level 5

Hi All,

im trying to upload attachment to the ServiceNOW record.

I was able to use cURL for downloading (GET) the attachemnts based on the File Meta-data i can get from HTTP GET request. So based on Attachemnt Sys ID.

I wanted to use again cURL for POST an attacment back to the SNOW, but i have troubles to make it work

For downloding i have this:
"curl "&[URL]&"/api/now/v1/attachment/"&[ServiceNow Attachment Sys ID]&"/file --request GET --header ""Accept:*/*"" --user "&[Username]&":"&[Password]&" -o """&[Destination File FullPath]&""""

For Upload i tried this in dozens of  variations based on the google results..

"curl "&[URL]&"/api/now/v1/attachment/file?table_name="&[ServiceNow Table name]&"&table_sys_id="&[ServiceNow Ticket Sys ID]&"&file_name="&[FileName]&" --request POST --header ""Accept:application/json"" --user "&[Username]&":"&[Password]&" --header ""Content-Type:application/pdf"" --data-binary """&[Source File FullPath]&""""

but it returns
{"error":{"message":"Method not Supported","detail":"GET method not supported for API"},"status":"failure"}'table_sys_id' is not recognized as an internal or external command,
operable program or batch file.
'file_name' is not recognized as an internal or external command,
operable program or batch file.

With this solution:
curl https://instance.service-now.com/api/now/v1/attachment/file --request POST --header "Accept:application/json" --user XXX:XXX --header "Content-Type:multipart/form-data" -F 'table_name=ABC_case' -F 'table_sys_id=8928dfbd1b164c903ca37669cd4bcb95' -F 'uploadFile=@C:/Temp/test.pdf'

i get: (26) couldn't open file "C:/Temp/test.pdf'"

Any help how to solve it or different ideas how to do it?
Im no programme. Have only some basic VB.NET skills. Noob in using Webservices 🙂



------------------------------
Pavel Král
RPA Specialist
MANN+HUMMEL Service s.r.o
------------------------------
4 REPLIES 4

IshanMahajan
Level 7
Hi Pavel, 

were you able to make this work ? are you using HTTP VBO and running Get and Post Action to utilize the cURL ? i am trying to achieve similar goals for a different API and need to upload a file using cURL.


------------------------------
Ishan Mahajan
India
------------------------------

Hi Ishan,

unfortunatelly i did not manage it, still i have it on my list, but currently busy with other stuff 😞



------------------------------
Pavel Král
RPA Specialist
MANN+HUMMEL Service s.r.o
------------------------------

HI Pavel,

i could not do this using Blue Prism but i created a batch file using Blue prism and i execute it using Start Process Action, upon execution i am writing the output in a textfile and i am reading that text file back to understand the run status.

------------------------------
Ishan Mahajan
India
------------------------------

GopalBhaire
Level 10
I think you are using GET to submit a POST request. I was able to use it to upload attachments please refer below screenshot.
Params
17544.png
Request
17545.png
Request Headers (you can parameterize the value as well)
17546.png






------------------------------
Gopal Bhaire
Analyst
Accenture
------------------------------