0

I have API which is using accesstoken as Header key and Value in Rest Assured

    Response response = httpRequest.request(Method.POST);
    //4. get the response body:
    String responseBody = response.getBody().asString();
    httpRequest.headers("accesstoken", "pbnQiOiIxMjM0NSJ9.");
    System.out.println("Response Body is: "+ responseBody);
    //validate city name or validate the key or value
    //Assert.assertEquals(responseBody.contains(city), true);


    //5. get the status code and validate it:
    int statusCode = response.getStatusCode();
    System.out.println("the status code is: "+ statusCode);

    Assert.assertEquals(statusCode, TestUtil.RESPONSE_CODE_200);

When I run the Rest Assured code, error message as 400.

Vipin Singh
  • 109
  • 1
  • 14

1 Answers1

0

I see that you are doing a POST request. 400 error message means its a bad request. So please check whether you are sending the body or not. If you are sending, please check

  1. Content-Type you are sending and expected. Is it application/json OR application/xml
  2. The input json has all necessary fields and valid values