You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

RestAssured调用Trello更新组织接口返回200但数据未更新求助

问题原因

  • 冗余传参问题:你已经在PUT请求的路径中拼接了目标组织IDorganizationId,不需要额外通过queryParam传入organizationId参数,该参数属于无效冗余参数。
  • 核心错误:参数传递格式不符合接口要求:Trello的组织更新接口不支持JSON格式的请求体,你放在body中的displayName、name参数不会被服务端解析,因此接口虽然返回200状态码,但实际没有执行任何更新操作,返回的是未修改的原组织数据。

修正方案

将需要更新的字段调整为查询参数传递即可,修正后的代码示例如下:

@Test(priority = 1)
public void updateOrganization() {
    Response response = given()
            .spec(reqSpec)
            // 移除多余的organizationId查询参数,将需要更新的字段作为查询参数传入
            .queryParam("displayName", "org")
            .queryParam("name", "test123")
            .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");
}

内容的提问来源于stack exchange,提问作者M.Sz

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.14 14:15:03