Extract data from multipart/form-data scripted rest api ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-30-2023 05:59 AM
Hello Community,
As the subject indicates, I am the next person trying to parse an inbound http multipart/form-data request. Because I need to make an api to integrate with a third party application. The attachment api is not applicable because the point is not to add an attachment to an existing record. But rather do all sorts of things based on the content of the uploaded file.
I've got as far as the input stream (ie. request.body.dataStream). I've tried GlideTextReader to get to the data. But I can't even find the boundary string. Even though a multipart request is only composed of text, I'm only getting gibberish. Maybe the encoding is wrong (is UTF-8).
Calling body.data, body.dataString, body.hasNext() all yield the error that these methods are not meant for multipart requests.
Typically when people ask for this they are directed to something like "https://docs.servicenow.com/bundle/geneva-servicenow-platform/page/integrate/inbound_rest/reference/.... Unfortunately those are all dead links now.
By any chance, does somebody in here still has this code ? Or can give me a clue how to proceed to get the body content ?
THX !