Solve Log Errors : Response status: 422, body: {"message":"Request body is not processable. Please check the errors.}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2020 01:11 PM
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2020 02:26 AM
Hi,
you need to check in that script include getAlertFromOpsGenie
In that script include are you consuming any endpoint? if yes then check if owner is set
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2020 02:31 AM
I found Script Include "OpsGenie_Client" in which below function exist:
getAlertFromOpsGenie: function (alertAlias) {
try {
var rest = new sn_ws.RESTMessageV2('x_86994_opsgenie.OpsGenie Alert API Endpoint', 'get');
rest.setRequestHeader("Authorization", "GenieKey " + this.apiKey);
rest.setStringParameter("endPoint", this.endpoint);
rest.setQueryParameter("identifierType", "alias");
rest.setStringParameter("subEndPoint", "/" + alertAlias);
rest.setRequestHeader("Content-Type", "application/json");
gs.debug("Sending GetAlert request to " + rest.getEndpoint());
var response = rest.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
var responseLogMessage = "Response status: " + httpStatus + ", body: " + responseBody;
if (!httpStatus.toString().startsWith("2")) {
gs.error(responseLogMessage);
} else {
gs.debug(responseLogMessage);
return responseBody;
}
} catch (ex) {
var message = ex.getMessage();
gs.error("Exception occurred: ", ex);
}
},
I don't see owner though.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2020 01:59 AM
Hi,
that owner key is missing
the 3rd party is expecting owner in the json request but you are not sending that
give valid value for owner i.e. user_name of the user
rest.setStringParameter("owner", value);
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2020 06:57 AM
Ankur,
Please see my updated function in Script Include "OpsGenie_Client" :
getAlertFromOpsGenie: function (alertAlias) {
try {
var rest = new sn_ws.RESTMessageV2('x_86994_opsgenie.OpsGenie Alert API Endpoint', 'get');
rest.setRequestHeader("Authorization", "GenieKey " + this.apiKey);
rest.setStringParameter("endPoint", this.endpoint);
rest.setQueryParameter("identifierType", "alias");
rest.setStringParameter("owner", user_name); //////////////Added here
rest.setStringParameter("subEndPoint", "/" + alertAlias);
rest.setRequestHeader("Content-Type", "application/json");
gs.debug("Sending GetAlert request to " + rest.getEndpoint());
var response = rest.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
var responseLogMessage = "Response status: " + httpStatus + ", body: " + responseBody;
if (!httpStatus.toString().startsWith("2")) {
gs.error(responseLogMessage);
} else {
gs.debug(responseLogMessage);
return responseBody;
}
} catch (ex) {
var message = ex.getMessage();
gs.error("Exception occurred: ", ex);
}
},
This user_name should come from where?
Are there any other changes than the script include?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2020 11:11 PM
Hi Nikita,
try sending some hard-coded user name and check what response you get
rest.setStringParameter("owner", gs.getUserName());
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader