Rest Assured 400 Bad Request

问题描述 投票:-1回答:1

我在放心地编写自动化代码,但是它返回400错误请求,并且我不知道如何调试它。希望有人能帮忙。

在邮递员中,我必须使用原始方法指定用户名和密码。它将对表单数据失败。 如何在保证安全的情况下指定原始数据?

Curl:

curl --location --request POST 'http://127.0.0.1:8010/api/v1/account/webapi/account/users/secure/webEncryptLogin?checkHash=false%0A' \
--header 'device_token: wap' \
--header 'Content-Type: application/json' \
--data-raw '{
  "username": "peter1",
  "password": "SomeSecretPassword"
}'

Rest保证的Java代码:

given().
                    contentType("application/json").
                    queryParam("checkHash", "false").
                    header("device_token", "wap").
                    params("username", "peter1", "password","SomeSecretPassword").
            when().
                    post("http://127.0.0.1:8010/api/v1/account/webapi/account/users/secure/webEncryptLogin").
            then().
                    log().ifError().
                    assertThat().
                    statusCode(200);

问题:

  1. 代码有什么问题吗?
  2. 如何放心地指定原始数据?
  3. 如何将访问令牌提取到字符串中?

请帮助。谢谢。

java rest web-services
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.