Scripted REST API POST method not inserting record into core_company table.

Devi12
Giga Guru

Hi,

I have created a scripted REST API POST method to insert a record into "core_company" table from third party. When I am testing in POSTMAN and Explore REST API It is showing status message as "200". But the record is not inserting into core_company table. How can I fix thie issue?

I am attaching the script I have used, may be this is causing the issue. Can anyone suggest how can I modify below script to insert the record.

find_real_file.png

11 REPLIES 11

Anil Lande
Kilo Patron

Hi,

Can you please share your script? It is not possible to read data from image and rewrite code.

 

Thanks,
Anil Lande

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

Anil Lande
Kilo Patron

Also can you please share how you are sending data from POSTMAN? What is payload included?

Also share what you configured in ServiceNow.

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

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

var sysID = request.pathParams.sysid;
var gr = new GlideRecord('core_company');
gr.addQuery('sys_id',sysID);
gr.query();
if(gr.next()){
var body = {};
body.name = gr.name;
body.website = gr.website;
body.notes = gr.notes;
body.status = gr.status;
body.business_owners = gr.business_owners;
response.setBody(body);
}
})(request, response);

this is the script in resource

After multiple tests I came to know that based on field type the record is not inserting into company table through Explore REST API.

When I am testing in p

ostman it is showing like this:

find_real_file.png

I have given below roles to the user:

find_real_file.png