Solve Log Errors : Response status: 422, body: {"message":"Request body is not processable. Please check the errors.}

Nikita35
Kilo Guru

hello 

I am working on minimizing log errors.

here are some 420 errors I see in the logs> Errors which says below:

Response status: 422, body: {"message":"Request body is not processable. Please check the errors.","errors":{"owner":"id or username should be provided"},"took":0.001,"requestId":"7e92211d-5896-4ed7-adbf-1c78f92241fe"}

Source is opsgenie

source script is a script include OpsGenie_Client.

How do I resolve these errors?

10 REPLIES 10

MrMuhammad
Giga Sage

Hi Nikita,

 

422 error occurs when you because of multiple reasons.

  • Incorrect or insufficient Request headers i.e when sending JSON data make sure Content-type | application/json has been set to send with the request. 
  • The request body is syntactically correct but semantically incorrect. Payload may be missing some values that are required by server to process.
  • May be validation is failing on the server side. 

You should check Request header and Request body to verify everything is up to the mark as required by your API to process. 

 

Please mark this correct & helpful if it answered your question.

Thanks & Regards,
Sharjeel

Regards,
Muhammad

can you help how do I navigate and where should this missing "owner" go as per in the log?

Hi Nikita,

please check the request body you are sending to 3rd party

It clearly says you are not sending anything in the owner json key

Ensure you set value in that json key and then check

If my answer solved your issue, please mark my answer as Correct & 👍Helpful based on the Impact.

Regards
Ankur

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

There is SCripted rest service under which several resources

Resource : Sample

Script:

(function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) {
var body = request.body.data;
var alertId = body.alert.alertId;

gs.info("[Sample] Processing message: " + new global.JSON().encode(body));


gs.info("[Sample] alertId: " + alertId);


var client = new OpsGenie_Client();
var alertFromOpsGenie = client.getAlertFromOpsGenie(alertId);

gs.info("[Sample] Response to Get Alert request from OpsGenie: " + new global.JSON().encode(alertFromOpsGenie));
})(request, response);

 

Am I looking at the correct place and Will I have to add "Owner" here?

If not please guide where I should look.