新浪微博发图片时报错

error:does multipart has image? error_code:20007/2/statuses/upload.json JAVA

新浪微博 官网sdk .

在调用 public Status UploadStatus(String status, ImageItem item) 这个接口发布带图片的微博时,出现如下异常:

  1. weibo4j2.model.WeiboException: 400:The request was invalid.  An accompanying error message will explain why. This is the status code will be returned during rate limiting.  
  2.  error:does multipart has image? error_code:20007/2/statuses/upload.json  
  3.     at weibo4j2.http.HttpClient.multPartURL(HttpClient.java:334)  
  4.     at weibo4j2.Timeline.UploadStatus(Timeline.java:765)  
  5.     at com.chineseall.util.SnsPostThread.run(SnsPostThread.java:51)  
  6.     at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)  
  7.     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)  
  8.     at java.lang.Thread.run(Thread.java:662)  
  9. Caused by: weibo4j2.model.WeiboException: 400:The request was invalid.  An accompanying error message will explain why. This is the status code will be returned during rate limiting.  
  10.  error:does multipart has image? error_code:20007/2/statuses/upload.json  
  11.     at weibo4j2.http.HttpClient.httpRequest(HttpClient.java:413)  
  12.     at weibo4j2.http.HttpClient.httpRequest(HttpClient.java:371)  
  13.     at weibo4j2.http.HttpClient.multPartURL(HttpClient.java:331)  
  14.     ... 5 more  

 

解决:

参数里的 ImageItem 这个对象,在 new 的时候,如果使用了 new ImageItem(name, content) 这个构造方法的话,

则 第一个参数 必须是 pic

  1. new ImageItem("pic",byteArrayOutStream.toByteArray());  

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值