HTTP Request - SNOW POST

API Post attachment of Excel file to Service Now is not allowing me to open after manually downloading attached file. Excel cannot open file “” because the file format or file extension is not valid. Verify that the file has not been corrupted and that the file extension matches the format of the file.

HTTP Request Activity - POST
Attachment - File path and name (with extension) - Ex: documents/Config.xlsx
Content-type = used nothing, document/excel, multi-part
Body = Empty
Body format = application/json

It is probable that you didn’t indicate filename extension or MIME type when executing POST. Can you provide more information? Like screenshot of HTTP Request activity properties

HTTP Properties:

correct Content-Type for xlsx file is:

application/vnd.openxmlformats-officedocument.spreadsheetml.sheet

That did not resolve the issue.
If I use the API Explorer in SNOW with the same file, I am able to successfully download and open the file.

Were you able to perform post to upload attachment using UiPath? Did you receive a 201 code?

Yes sir.

Can you share link to ServiceNow API Docs you are using?

ServiceNow Developers along with API explorer doc in SNOW to test out manually.

I am using /api/now/attachment/file from a binary request (not from a multipart form).

As I can see you must set mime type depending on your file format. For xlsx, use:

application/vnd.openxmlformats-officedocument.spreadsheetml.sheet

This must be set in BodyFormat property

In parameters you also have to define the correct file name including extension.

And in Body property you need to include binary content from file (for example):

image

Hope it helps!

Switched to /api/now/attachment/upload and everything worked as expected.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.