Post Method Error

ruuhverr
Kilo Explorer

Hello Everone,

I want to create a record using Scripted Rest Api.

Here is my code:

(function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) {

var gr=new GlideRecord('sn_customerservice_case');

gr.initialize();

gr.description="Testing going on"

gr.impact="4";

var abc=gr.insert();

return "Sys id is "+abc;

})(request, response);

When I am inserting a its showing this error from POSTMAN

Error:

{

      "error": {

              "detail": "",

              "message": "java.lang.IllegalArgumentException: Cannod decode: java.io.StringReader@1142887"

      },

      "status": "failure"

}

1 ACCEPTED SOLUTION

Hi Rahul,



In postman add the content body in the body part and select raw as the format then you should get an area to put the json request body and add the body there and hit the endpoint


format in your earlier screenshot is form-data make it to raw



Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.


Thanks


Ankur


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

View solution in original post

8 REPLIES 8

Hi Rahul,



In postman add the content body in the body part and select raw as the format then you should get an area to put the json request body and add the body there and hit the endpoint


format in your earlier screenshot is form-data make it to raw



Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.


Thanks


Ankur


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

Thanks Ankur, for your answer.


My whole day got wasted in this small thing.


That was a learning for you and should be fine.



Could you also mark it as helpful and hit like. If you wish you can endorse the content as well.


Thanks in advance.


How to Endorse Content



Regards


Ankur


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

Thanks for your help Ankur. Ya basically I am new to Servicenow so learning from my mistakes.


I already marked it as helpful.