The CreatorCon Call for Content is officially open! Get started here.

REST Multipart/form-data binary image request body?

Nick65
Mega Expert

So I have been working on an integration and was curious if anyone has successfully created a multipart/form-data outbound REST request with binary image data in Servicenow? With or without use of mid server. I know the request works because it works fine in Fiddler and Restify. Below is the body I am using, I have been able to post this exact message with a text file so I know the issue is with the binary I am sending. I have also tried base64. Does anyone have any tips or tricks for sending binary image data with Javascript? Any pitfalls or issues you have ran into in the past? Thanks !

--gc0p4Jq0M2Yt08jU534c0p

Content-Disposition: form-data; name="body"


goes with message

--gc0p4Jq0M2Yt08jU534c0p

Content-Disposition: form-data; name="attachment1"; filename="testpic.gif"

Content-Type:image/gif

Content-Transfer-Encoding: binary


${attachment}

--gc0p4Jq0M2Yt08jU534c0p--

1 ACCEPTED SOLUTION

Yes, I finally got this done with a custom .jar file and Javascript probe. I wrote a reply on


JavascriptProbe and MID Server Script Includes-John Andersen


I believe you must be the same Jonathan, let me know if you have any questions.


View solution in original post

15 REPLIES 15

Hello Jonathan,

I'm using the same code as your above, but I'm stuck in the following response: "Evaluation error: HTTP response 403 (script_include:CopyAttachments; line 31)"

Does anybody have any idea what can be wrong, since I'm pretty sure that all the user credentials and permissions are okay..?

Any help would be appreciated! Thanks in advance!