【问题标题】:Rest Assured - shows bad request放心 - 显示错误的请求
【发布时间】:2016-06-21 23:31:27
【问题描述】:

这是我的请求 xml:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Request>
    <user>
        <title>Mr</title>
        <firstname>automation</firstname>
        <lastname>Qa</lastname>
        <department>Automation</department>
        <mobile>999000777</mobile>
    </user>
</Request>

这是我的实际放心代码:

String APIUrl = "http://autoTest.com/api/1/user/create";

        HashMap<String, String> hashMap = new HashMap<>();

        hashMap.put("title", "Mr");
        hashMap.put("firstname", "automation");
        hashMap.put("lastname", "testing");
        hashMap.put("department", "test");
        hashMap.put("mobile", "7878787");

        Response response = RestAssured.given().auth().preemptive() .basic("userName", "passw0rd"). 
parameters(hashMap).when().post(APIUrl);

当我拨打这个电话时,它会给我以下控制台错误:

Bad request ,
Request resource or xml is not valid ,
Sorry, we could not find appropriate method or xml.

谁能帮我找出我做错了什么?

【问题讨论】:

    标签: post rest-assured


    【解决方案1】:

    您可能需要添加 contentType("application/xml") 以便放心知道它应该将地图序列化为 XML。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-01-08
      • 1970-01-01
      • 2018-07-29
      • 1970-01-01
      • 1970-01-01
      • 2019-06-30
      • 1970-01-01
      相关资源
      最近更新 更多