Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to attach file same as OOB table api in postman from scripted web services ?

Thej1
Tera Expert

Hi,

 

Can we able to attach a file from the postman same as OOB table api from the scripted web services ?

The below screenshot is of the sending attachment by using the OOB table api.

image (7).png

 

But for the custom scripted web services, we are send request in JSON body as below but not in multipart/form-data.

{
  "incidentNumber""INC0010002",
  "fileName""Testtt.png",
    "contentType""image/png",
  "fileData": "Base64 code"
}
Is there a way to do it to send request in form-data same as of the OOB table api for the custom scripted web service ?
 
Thanks
1 ACCEPTED SOLUTION

@Thej1 

it's not able to read the file data hence went inside No file uploaded

You can check the links I shared above, some solution might be present there

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

14 REPLIES 14

Ankur Bawiskar
Tera Patron
Tera Patron

@Thej1 

I don't think.

Scripted REST API accepts json request body

why you don't want to use json request body?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi @Ankur Bawiskar 

 

Can't we be able to send file directly from postman as content type form data in Scripted REST api as we do in OOB Attachment API ?

Need to send request in JSON for Scripted REST api ?

 

Thanks

@Thej1 

for that your scripted REST API should be able to parse and get the data from multi-part form data

I haven't explored much on it but I will suggest to use JSON data

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Thej1 

Thank you for marking my response as helpful.

I believe I have answered your original question.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader