Live Helper Chat support forum.. Old google groups forum can be found here

You are not logged in.

Announcement

#1 2021-03-01 03:40:55

shrnt
New member
Registered: 2020-10-19
Posts: 9

Add user attachment via API

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

#2 2021-03-01 06:30:51

remdex
Administrator
From: Lithuania
Registered: 2012-09-23
Posts: 3,487
Website

Re: Add user attachment via API

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

#3 2021-03-01 06:48:34

shrnt
New member
Registered: 2020-10-19
Posts: 9

Re: Add user attachment via API

hello! thank you for the quick response. The BBCode will work  smile

and thanks for looking into file handling to API!

Offline

#4 2021-03-03 09:32:09

remdex
Administrator
From: Lithuania
Registered: 2012-09-23
Posts: 3,487
Website

Re: Add user attachment via API

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

#5 2021-03-30 14:46:34

karlitoxz
Member
Registered: 2021-02-10
Posts: 12

Re: Add user attachment via API

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.
1617115579_lhc_001.jpg

Offline

#6 2021-03-30 14:53:14

remdex
Administrator
From: Lithuania
Registered: 2012-09-23
Posts: 3,487
Website

Re: Add user attachment via API

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

#7 2021-03-30 15:01:28

karlitoxz
Member
Registered: 2021-02-10
Posts: 12

Re: Add user attachment via API

I thought so, but all these types of files are allowed:
1617116478_lhc_001.jpg

Offline

#8 2021-03-30 15:02:01

remdex
Administrator
From: Lithuania
Registered: 2012-09-23
Posts: 3,487
Website

Re: Add user attachment via API

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

#9 2021-04-07 14:22:46

karlitoxz
Member
Registered: 2021-02-10
Posts: 12

Re: Add user attachment via API

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?

1617805322_lhccurl.jpg

and thanks for all the help you have given me :-)

Offline

#10 2021-04-07 14:36:21

remdex
Administrator
From: Lithuania
Registered: 2012-09-23
Posts: 3,487
Website

Re: Add user attachment via API

Curl works for me as long it’s copied from swagger smile

Offline

#11 2021-04-07 14:54:49

karlitoxz
Member
Registered: 2021-02-10
Posts: 12

Re: Add user attachment via API

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

Board footer