error issue in Rest

angel kumari
Tera Contributor

hi all,

i am using this script to creat  aincident. and after test it then this error show.

 

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

// implement resource here
var req = request.body.data;
var category = req.category;
var subCat = req.subCategory;
var caller = req.caller;
var sd = req.short_description;
var desc = req.description;
var impact = req.impact;
var urgent = req.urgency;


var gr = new GlideRecord('incident');
gr.initialize();

gr.caller_id = caller;
gr.short_description = sd;
gr.description = desc;
gr.impact = impact;
gr.urgency = urgent;
gr.category = category;
gr.sub_category = subCat;
var id = gr.insert();

var res= {id : id};
response.res=res;
})(request, response);

2 ACCEPTED SOLUTIONS

Rahul RJ
Giga Sage
Giga Sage

Hi @angel kumari ,

There is a problem with the username and password. Can you check the credentials and try?

 

Regards,

RJ

 

View solution in original post

Ratnakar7
Mega Sage
Mega Sage

Hi @angel kumari ,

 

It seems you are getting 401 error code as response output, 

401

Unauthorized. The user credentials are incorrect or have not been passed.

 

Please verify that you are using correct username and password from respective servicenow instance, additionally that user should have proper role to create an incident record, you can try with giving "itil" role to that sys_user record.

 

I hope this solves your issue
Mark this as Helpful / Accept the Solution if this clears your issue

 

Thanks,

Ratnakar

View solution in original post

5 REPLIES 5

Rahul RJ
Giga Sage
Giga Sage

Hi @angel kumari ,

There is a problem with the username and password. Can you check the credentials and try?

 

Regards,

RJ

 

yes i m using mu user as admin  or pwosd which is there but again  shows

 

@angel kumari  Ideally we used to use service accounts for the integration with required permissions.

 

Regards,

RJ

hi 

why this error show on testing when i pass the value as in contect.

 

{
"error": {
"message": "com.glide.rest.util.RESTRuntimeException: The payload is not valid JSON.",
"detail": ""
},
"status": "failure"
}