2

我正在尝试使用放心的框架上传文件。该调用是对我正在使用的 API 的 POST 调用,代码如下所述:

             given()
            .contentType("image/jpg")
            .accept("application/json")
            .auth().oauth2(accessToken, OAuthSignature.QUERY_STRING)
            .multiPart(new File("C:/Snap0000.jpg"))
            .post("/objects/files")
            .getBody();

这样做时我得到的错误是:

400 - Unable to read image info Couldn't read magic numbers to guess format.

我究竟做错了什么?

4

1 回答 1

1

您可能缺少多部分的控件名称?有关 multiPart 方法的信息,请参见 javadoc 或查看文档

编辑:上面的链接(部分)坏了;github上的这个似乎效果更好:https ://github.com/rest-assured/rest-assured/wiki/Usage#multi-part-form-data

于 2015-03-16T18:44:33.007 回答