Yammer REST API-发布带有附件的消息

时间:2019-08-01 18:31:10

标签: java rest api yammer

我正在尝试集成Yammer REST API,以根据文档https://developer.yammer.com/docs/messages-json-post使用具有附件的JAVA将消息发布到组中。

到目前为止,什么对我有用:

  • 能够使用邮递员发布没有附件的邮件
  • 能够使用JAVA程序发布不带附件的邮件
  • 能够使用邮递员发布HTML消息而没有附件(使用“公告”功能)
  • 能够使用JAVA程序(使用“公告”功能)发布不带附件的HTML消息
  • 能够使用邮递员发布带有附件的HTML消息(使用“公告”功能)

但是,我无法

  • 使用Java程序发布带有附件的HTML消息

下面是代码段-

File fileToUse = new File("logo.png"); 
FileBody fileBody = new FileBody(fileToUse, ContentType.MULTIPART_FORM_DATA);
StringBody stringBody1 = new StringBody("12345", ContentType.MULTIPART_FORM_DATA);

MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.addPart("attachment1", fileBody);
builder.addPart("group_id", stringBody1);

HttpEntity entity = builder.build();

httpPost.setEntity(entity);
HttpResponse response = client.execute(httpPost);

有人遇到这个问题吗?感谢您对此的想法。

得到以下错误:

HttpResponseProxy {HTTP / 1.1 500 Internal Server Error [X-Cell-Id:5,X-Network-Id:13570,Strict-Transport-Security:max-age = 1234513412313; includeSubDomain,X-Robots-Tag:无,X-Lodbrok-Cell:prod_central_1_static-c5,X-MSEdge-Ref:Ref A:A7FDC286B58B43A1A70D5F197905860B Ref B:CH1EDGE1105 Ref C:2019-08-01T20:14:48Z,日期:Thu ,2019年8月1日20:14:48 GMT,Content-Length:0] [Content-Length:0,Chunked:false]} [Content-Length:0,Chunked:false]

0 个答案:

没有答案