Live Helper Chat support forum.. Forum is locked. New place for questions - Github Discussions
You are not logged in.
Pages: 1
Hello again! I would like to know if it is possible to add an attachment from user via API
I am looking at the ChatMessage model in /restapi/addmsguser.
How do I handle attachments? Is it from passing data in meta_msg? What do i need to include?
Thank you!
Offline
Hi,
At the moment there is no API for files attatchements. But if you are storing them somewhere else you can always pass just a link to file https://doc.livehelperchat.com/docs/chat/bbcode/
I have added to my todo list to add files handling API in next week or two.
Offline
hello! thank you for the quick response. The BBCode will work
and thanks for looking into file handling to API!
Offline
New api
https://api.livehelperchat.com/#/file
Also if you look here there is new example how you can use bbcode to get custom link title
https://doc.livehelperchat.com/docs/chat/bbcode/
Offline
Good morning, I have tried to upload a file through the API without success, the authorization is fine, and in configuration I have the file upload enabled, I attach an image of the error.
Offline
That's correct response if you are uploading file which type is not allowed.
Check for your file uploade configuration api works as expected.
See swagger for api
https://api.livehelperchat.com/#/file/post_restapi_file
Offline
I thought so, but all these types of files are allowed:
Offline
SO it means you are not sending correct request use swagger for testing.
This is sample how curl looks on my dev environment
curl -X POST "https://devmysql.livehelperchat.com/restapi/file" -H "accept: application/json" -H "authorization: Basic YWRtaW46YWRtaW4x" -H "Content-Type: multipart/form-data" -F "files=*** - 20190103.pdf;type=application/pdf" -F "name_prepend=rwar" -F "name_replace=file.pdf"
Offline
ok, you were right it was something very simple, I was sending an incorrect parameter, it was not "file", the correct one is "files"; with postman it already works for me.
I tried curl but I think it does not reach the API with the indicated format "/ restapi / file", have you had experience uploading files in this way?
and thanks for all the help you have given me :-)
Offline
Curl works for me as long it’s copied from swagger
Offline
Thank you,
In case it works for someone else, solve it by adding parameters to the header:
$ headers = array ("Content-Type" => "multipart / form-data");
curl_setopt ($ ch, CURLOPT_HTTPHEADER, $ headers);
Offline
Pages: 1