- 接口地址:<a href="https://open.youzan.com/v3/apicenter/doc-api-main/1/2/storage/youzan.materials.storage.platform.img.upload">https://open.youzan.com/v3/apicenter/doc-api-main/1/2/storage/youzan.materials.storage.platform.img.upload</a>
复制代码
问题:
这个接口请求体的参数不管是image还是image[],又或者值为byte[]还是java.io.File;代码如下:
- public static void shopImg() throws IOException {
- String url = "https://open.youzan.com/api/oauthentry/youzan.materials.storage.platform.img/3.0.0/upload?access_token=" + YouZanUtil.getAccessToken();
- String imgpath = "D:/usr/2015051915.jpg";
- byte[] bytes = YouZanUtil.fileToByteArray(imgpath);
- File file = new File(bytes);
- MultiValueMap<String, Object> paramMap = new LinkedMultiValueMap<>();
- paramMap.add("image[]", file);
- paramMap.add("image", file);
- paramMap.add("image[]", bytes);
- paramMap.add("image", bytes);
- String json = new RestTemplate().postForObject(url, paramMap, String.class);
- System.out.println(json);
- }
复制代码
返回的结果都是
- {
- "error_response": {
- "code": 53001,
- "msg": "image[] cannot be empty"
- }
- }
复制代码 求解?
|
|
用手机打开
收藏
赞 0
···
回复
|
|
|
|