Is there a way to create a Scripted Rest API to receive and process multipart/form-data?

gcm1
Tera Expert

I am attempting to develop a custom Scripted REST API that can handle POST requests with a content-type of multipart/form-data within a scoped application. However, everything I have tried either results in an error or leads to this issue:

 

{ "error": { "message": "com.glide.rest.domain.ServiceException: Server error: attempted to access operations that are not allowed when request content is multipart/form-data", "detail": "" }, "status": "failure" }

 

or this issue:

 

{

"error": {
"message": "com.glide.rest.domain.ServiceException: Server error: attempted to access operations that are not allowed when request content is multipart/form-data; boundary=--------------------------443473985528007832469733",
"detail": ""
},
"status": "failure"
}
 
I don't want to use the OOB attachment API because I need to return custom response for the customer and also handle the form fields according.
 
Thank you in advance.
2 REPLIES 2

Allen Andreas
Administrator
Administrator

Hi,

Unfortunately, there seems to be a trend of that type having problems within the platform. Have you reviewed this thread/conversation to see if that assists you?

https://www.servicenow.com/community/developer-forum/inbound-multipart-form-data-via-the-scripted-re... 

 

Also this which helps sort of talk about how to use "other" methods: https://snprotips.com/blog/2019/11/18/handling-textplain-and-other-unsupported-content-types-in-scri... 


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Sumanth16
Kilo Patron

Hi @gcm1 ,

 

 

Please refer to below article:
https://www.servicenow.com/community/developer-articles/script-to-send-multipart-including-text-and-...

https://www.servicenow.com/community/developer-forum/inbound-multipart-form-data-via-the-scripted-re...

 

If I could help you with your Query then, please hit the Thumb Icon and mark it as Correct !!

 

Thanks & Regards,
Sumanth Meda