sharma16
sharma16

Reputation: 11

In rest assured framework,I am sending path params in one request but they are being send with another request as well. How can we remove path params?

    @Test(description = "Verify that user is able to login and get the offer details for a particular promo code", dependsOnGroups = "getAuthKey")
    public void verify_offers_with_login_with_promo_code() {
        Map<String, String> headers = InputRequestHelper.setHeaders("auth_api_key", auth_api_key);

        **// Have to remove the below set path parameters later in the code**
        requestSpecification.pathParam("promocode", "1909");
        Response response = InputRequestHelper.createGetRequest(requestSpecification, captor,
                Constants.OFFER_PROMOCODE_PATH, headers, "com.dhani/schemas/offers/offersPromocode.json");
        CommonHelper.writeRequestAndResponseInReport(writer.toString(), response.prettyPrint());
        JSONObject jsonObject = new JSONObject(response.getBody().asString());

        AssertionHelper.assertNotNull(ParseDynamicJson.getKey(jsonObject, "data"), "data");
        AssertionHelper.assertFieldValue(ParseDynamicJson.getKey(jsonObject, "message"), "success", "message");
    }

Upvotes: 0

Views: 802

Answers (1)

lucas-nguyen-17
lucas-nguyen-17

Reputation: 5917

There is no way remove config in RequestSpecification --> shouldn't re-use this. You have to create new instance of this class for every request.

Similar situation here: https://stackoverflow.com/a/69569031/7574461

Upvotes: 0

Related Questions