How to set request body as attachment plus json payload to call API in servicenow

supriyanika
Giga Contributor

how we can set attachment and json body as request body in servicenow to call the api i tried below script but it it sending binary data and api is not accepting binary data

 
 

WhatsApp Image 2026-02-24 at 7.29.34 PM.jpeg

1 REPLY 1

yashkamde
Kilo Sage

Hello @supriyanika ,

 

Try converting your JSON to string and then set to the request-body.

r.setRequestBody(JSON.stringify(body));

 

If my response helped mark as helpful and accept the solution.