我正在尝试使用API发送附件到工单,确保它是多部分/表单数据发送,但是我不能做so.The API文档没有显示它应该与语法发送的示例,所以我不知道如何做。数据的发送方式:
Input::all();
$json = json_encode(
array(
"helpdesk_note" => array(
"body" => Input::get('reply'),
"user_id" => $requester_id,
"private" => true,
"attachments" => array(
Input::get('photo')
)
)
)
);
$this->curlWrap("tickets/".$ticket_id."/conversations/note.json", $json, "POST");发布于 2016-03-08 04:20:56
您这样做是错误的,请注意,附件需要是multipart/form-data格式,并且您正在尝试将正文作为JSON传递。新办公桌不允许这样做。
请阅读此RFC1867,你可以做到这一点!请注意第6节中的示例。
你需要将你的身体放在下面的格式中:
Content-type: multipart/form-data, boundary=AaB03x
--AaB03x
content-disposition: form-data; name="helpdesk_note[body]"
Your message here.
--AaB03x
content-disposition: form-data; name="helpdesk_note[attachments][][resource]"; filename="fileSomeName.jpg"
Content-Type: image/jpeg
... contents of fileSomeName.jpg here ...
--AaB03x--您还需要设置以下标头:
Content-Type: multipart/form-data
Content-Length: 2632Content-Length必须是所有正文的精确大小。
https://stackoverflow.com/questions/26698009
复制相似问题