上传文件到消息鸟API

Uploading a file to Message Bird API

目前,我正在尝试将消息鸟 API 集成到我的自动化应用程序 (https://developers.messagebird.com/) 中。

我正在尝试使用消息鸟 API 上传文件,正如文档所述,我正在使用此端点:https://messaging.messagebird.com/v1/files that returns me the id of the file that I uploaded, the problem is that when I try to join that ID with the endpoint to get the file (https://messaging.messagebird.com/v1/files/:id-of-the-file) 并将 URL 用于内容我要发送的消息(

content: {
   image:{
    url:"https://messaging.messagebird.com/v1/files/:id-of-the-file"
  }
}

), 消息未传递并且 webhook return 给我一个失败的状态(即消息未传递到通道),我猜这是因为为了得到我需要对自己进行身份验证的文件,但我无法仅通过发送 URL 来对自己进行身份验证。此外,我尝试将 URL 作为图像的 base64 发送,但它也不起作用,我不知道我是否做错了或者那不是我必须使用的端点或什么。如果您能帮助我,我将不胜感激:)

PD:当我通过邮递员在 headers 中发送 AccessKey 发出请求时,它确实 return 我得到了图像

您应该将图片上传到消息 API endpoint only if you want to include them in email message. Once they have uploaded you can use the id's returned in either the inlineImage field, or the attachments field, as seen in this json example

如果您尝试通过其他平台(即 whatsapp、telegram)发送图片,您应该能够将您的图片 url 作为请求的一部分,如下例所示。

不确定您使用哪个端点发送消息,但此 json 对对话有效 /conversations/send endpoint. You can also use the same structure for the content field on these endpoints too (/conversations/start or /conversations/{id}/messages)。

{ 
   "to":"+11111111",
   "channelId":"mychannelid",
   "type":"image",
   "content":{ 
      "image":{
        "url":"https://example.com/an_image.png"
      }
   }
}

希望这能解决您的问题!如果没有,您能否提供更多有关平台和您使用的端点的信息。

谢谢