Integration giving 400 error , when i trigger it

Priya75
Tera Contributor

Hi All,

I have a Business rule from where i am triggering this integartion it is in a "XYZ" scope. 

and my rest message is in Global scope ,v i have changed the setting to All scope

This is giving me error. 400

 

    try {
        requestBody = {

            extra_vars:{
                data: {
                    _cmd: "abc",
                    hostname: "loncsdx",
                    database: "testdb01"
                   
                }
            }
        };
        strRequestBody = JSON.stringify(requestBody);

        sm = new sn_ws.RESTMessageV2("global.testApi", "Post");
        sm.setRequestBody(strRequestBody);
        sm.setMIDServer(midserver);
        sm.setRequestHeader("Content-Type", "application/json");
        sm.setEccParameter('skip_sensor', true);
        response = sm.execute();

        responseBody = response.haveError() ? response.getErrorMessage() : response.getBody();
        status = response.getStatusCode();
    } catch (ex) {
        responseBody = ex.getMessage();
        status = '500';
    } finally {
        strRequestBody = sm ? sm.getRequestBody() : null;
    }

4 REPLIES 4

Tom Sienkiewicz
Mega Sage

Status 400 means your are most likely not passing a correct payload or failing some validations in target system.

Check if there is any additional message to go with status 400 in the response. Maybe that will provide more context.

What system/API are you connecting to?

Method failed: (/api/v2/job_templates/66/launch/) with code: 400

 

I am getting this error.

Nayan  Dhamane
Kilo Sage
Kilo Sage

Hello Priya,

As Tomas said status 400 means your are most likely not passing a correct payload or failing some validations in target system.

But I would to know what response body are you getting after executing it. so I could help you ahead.

BR,
Nayan

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

Best Regards,
Nayan Dhamane
ServiceNow Community Rising Star 2023.

Method failed: (/api/v2/job_templates/66/launch/) with code: 400

 

 

this is i am getting in response