The Now Platform® Washington DC release is live. Watch now!
‎10-18-2014 09:21 PM
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--
Solved! Go to Solution.
‎12-21-2014 10:11 PM
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.
‎11-15-2014 01:57 PM
Nick,
Have you had any luck with this?
‎11-15-2014 05:17 PM
Uhg no, its been tough. Don't think this is even possible with the mid server because of the parsing that happens, every time I have tried this with a mid server I get xml parsing errors. This has also been hard because I don't know where I can or if its even possible to debug outbound rest messages in ServiceNow. I know that rest debug system property can be added but that seems to be strictly inbound rest messages. Another challenge is I know how to get this to a base64 encoded image but when I send that to Yammer its broken, and I am not sure if Yammer even accepts base64 encoded images. And finally another issue I have is when I tried to use Java Package calls I don't know how to call the one I need to build a multi part request. I know the package name is org.apache.http.entity.mime.MultipartEntityBuilder; but have not had success initializes it. So yea,no luck.
‎11-15-2014 09:32 PM
And don't get me wrong its not formatting the multipart body, that works fine with plain/text, its the image/binary territory.
‎12-21-2014 10:11 PM
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.