Nick
Nick

Reputation: 100

How to pass several parameters via pathParam() [REST-ASSURED, API]

How do I pass several parameters via pathParam() in the following rest-assured POST request?

I tried this:

enter code here

createBaseRequest(userRequestSpecification)
                .when()
                .contentType(ContentType.JSON)
                .pathParam("permalink", requestExpertTeam.getPermalink())
                .pathParam("id", parseInt(getLoggedUserId(userRequestSpecification)))
                .put(ENDPOINT_ADD_USER_TO_EXPERT_TEAM)
                .then()
                .extract()
                .as(UserDTO.class);

But the IntelliJ starts yelling:

java.lang.IllegalArgumentException: Path parameters were not correctly defined. Redundant path parameters are: id=252.

When I change 'pathParam' in [pathParam("id", parseInt(getLoggedUserId(userRequestSpecification)))] to 'queryParam' IntelliJ starts yelling that it expects two params but got only one.

Thank you in advance.

Upvotes: 0

Views: 1839

Answers (1)

lucas-nguyen-17
lucas-nguyen-17

Reputation: 5917

You missed the placeholder in URL for pathParam id. If RA see that mismatch between pathParam and URL, they will fire an error.

.pathParam("permalink", "abc")
.pathParam("id", 1)

http://localhost:8080/{permalink}/{id}

Upvotes: 1

Related Questions