如何在Java中以原始格式发送请求

如何在Java中以原始格式发送请求,java,rest-assured,Java,Rest Assured,我的客户要求我对api进行测试,其中请求的主体应该是一个原始的,而不是头或者其他的 他在《邮递员》中向我展示了如何做到这一点,但我希望通过Java和rest assured中的自动化来模拟这一点 那么如何在java中实现这一点,因为我可以通过java中的get或post来实现,然后重新发行,但不知道如何使用raw 得到- @测试 公共无效mytest(){ Map paramSample=新的HashMap(); 参数样本放置(“v”、“X.X”); 参数示例放置(“标题”、“X”); 参数样

我的客户要求我对api进行测试,其中请求的主体应该是一个原始的,而不是头或者其他的

他在《邮递员》中向我展示了如何做到这一点,但我希望通过Java和rest assured中的自动化来模拟这一点

那么如何在java中实现这一点,因为我可以通过java中的get或post来实现,然后重新发行,但不知道如何使用raw

得到-

@测试
公共无效mytest(){
Map paramSample=新的HashMap();
参数样本放置(“v”、“X.X”);
参数示例放置(“标题”、“X”);
参数样本放置(“本地”、“X”);
参数样品放置(“方法”,“xxxxx”);
paramSample.put(“json”,CreateJSON(ExecutionConfig.xxxx,0,0,ExecutionConfig.xxxxx,“Mex”);
paramSample.put(“发送方”,ExecutionConfig.xxxx);
paramSample.put(“api_键”,ExecutionConfig.xxx);
paramSample.put(“格式”、“json”);
RequestSpecification请求=给定();
Response responseSample=request.params(paramSample).get(ExecutionConfig.mxxx).then().extract().Response();

您只需设置given().contentType(“text/plain”)@Wilfred Clement我这样做了,但是我需要在哪里传递原始的正文内容?我可以问一下为什么要传递正文来进行GET调用吗?传递正文来进行GET调用没有任何意义这就是我从客户端获得它的方式,而且他们说它将与GET&Post方法一起工作。Post方法将有有效负载,但GET永远不会有有效负载
@Test
    public void mytest() {

        Map<String, String> paramSample = new HashMap<>();
        paramSample.put("v", "X.X");
        paramSample.put("headers", "X");
        paramSample.put("local", "X");
        paramSample.put("method", "xxxxx");
        paramSample.put("json", CreateJSON(ExecutionConfig.xxxx,0,0,ExecutionConfig.xxxxx,"Mex"));
        paramSample.put("sender", ExecutionConfig.xxxx);
        paramSample.put("api_key", ExecutionConfig.xxx);
        paramSample.put("format", "json");
        RequestSpecification request = given();
        Response responseSample = request.params(paramSample).get(ExecutionConfig.Mxxxxx).then().extract().response();