【问题标题】:API how to use Post QueryStringAPI 如何使用 Post QueryString
【发布时间】:2022-07-04 23:46:34
【问题描述】:

请放心 - API 如何使用后查询字符串我无法通过这个。我必须手动勾选或取消勾选。

我们需要使用 Post 查询字符串发送数据,而不是从媒体类型发送数据:

 response = given()
.header()
.log()
.when()
.post()
.then() 

【问题讨论】:

    标签: rest-assured


    【解决方案1】:

    只是内容类型application/x-www-form-urlencoded

    例如:

    given().log().all()
            .config(RestAssured.config()
                            .encoderConfig(encoderConfig().appendDefaultContentCharsetToContentTypeIfUndefined(false)))
          .contentType(ContentType.URLENC)
          .formParam("name", "john.smith")
          .formParam("firstName", "john")
          .formParam("lastName", "Smith")
          .formParam("email", "js@jscompany.com")
          .post("https://postman-echo.com/post")
          .prettyPrint();
    

    【讨论】:

      猜你喜欢
      • 2012-12-27
      • 1970-01-01
      • 1970-01-01
      • 2021-02-23
      • 2013-02-18
      • 1970-01-01
      • 2022-01-24
      • 2022-12-20
      • 2023-04-06
      相关资源
      最近更新 更多