M.Sz
M.Sz

Reputation: 63

Data is not updated despite status 200 - rest assured

I'm trying to send put request to trello api (https://developer.atlassian.com/cloud/trello/rest/api-group-organizations/#api-organizations-id-put). I've got response with status 200 but data is not updated. Here is my request:

@Test(priority = 1)
public void updateOrganization() {
    JSONObject organization = new JSONObject();
    organization.put("displayName", "org");
    organization.put("name", "test123");

    Response response = given()
            .spec(reqSpec)
            .queryParam("organizationId", organizationId)
            .body(organization)
            .when()
            .put("https://api.trello.com/1/organizations" + "/" + organizationId)
            .then()
            .statusCode(200)
            .extract()
            .response();

    JsonPath json = response.jsonPath();
    System.out.println(response.asString());
    organizationId = json.getString("id");
    organizationName = json.getString("name");
    Assert.assertEquals(organizationName, "test123");
}

And here is response:

{"id":"60db4c31ff40b31e7ce3591f","name":"test95159884","displayName":"organization","descData":{"emoji":{}},"website":null,"teamType":null,"desc":"","url":"https://trello.com/test95159884","logoHash":null,"logoUrl":null,"products":[],"powerUps":[]}

Can someone tell me what am I doing wrong?

Upvotes: 1

Views: 485

Answers (1)

lucas-nguyen-17
lucas-nguyen-17

Reputation: 5917

It seems to me that when you call the API using above code, the final URL will be:

"https://api.trello.com/1/organizations/{organizationId}?organizationId={organizationId}"

In the API docs, the request just need organizationId as Path parameter, not Query Parameter.

My suggesstion is removing the code:

.queryParam("organizationId", organizationId)

Upvotes: 1

Related Questions