Live Helper Chat support forum.. Forum is locked. New place for questions - Github Discussions

You are not logged in.

Announcement

#1 2020-12-20 19:29:29

evgen.galkin
New member
Registered: 2020-12-18
Posts: 4

RestApi POST method error

Hello.
I want to collect visitors name, phone, some attribute and than send this info by RestApi to my php script, which creates new lead in my crm system.

If I use GET method, it works only if my attribute dont have space symbol, otherwise I got error "400 Bad Request" from server, which is shown in chat widget.

If I use Post Method I always get error "400 Bad Request".

What is wrong can be?

1608492434_2020-12-20_212046.jpg
1608492460_2020-12-20_212056.png
1608492482_2020-12-20_212140.png
1608492505_2020-12-20_212322.jpg

Offline

#2 2020-12-20 19:42:40

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

Re: RestApi POST method error

I do not think it's related to LHC itself. More to the script itself. What response you see is the response from server directly. So your php script is not handling request properly.

And i would just use post parameters in body. By choosing request as form data and adding your parameters there. You can always debug be looking to https://github.com/LiveHelperChat/liveh … i.php#L131

Also in rest api response you can use special placeholeders while debuning in text messages like https://doc.livehelperchat.com/docs/bot … n-triggers


{http_code} - https status code returned from request
{http_error} - additional error explanation from curl_error($ch);
{content_raw} - raw response returned from Rest API call without any parsing
{http_data} - Request parameters used for rest api call.

In any case it's problem on your end.

Offline

#3 2020-12-20 19:50:10

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

Re: RestApi POST method error

Also as you are using nginx please check your nginx parameters

https://doc.livehelperchat.com/docs/ngi … ation-tips

Offline

#4 2020-12-20 20:00:29

evgen.galkin
New member
Registered: 2020-12-18
Posts: 4

Re: RestApi POST method error

remdex wrote:

Also as you are using nginx please check your nginx parameters

I think the reason is in custom nginx settings, which should be set. But I cannot do that, because this is virtual hosting.
I checked my script via reqbin dot com and it works fine.

Offline

#5 2020-12-20 20:02:56

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

Re: RestApi POST method error

For sure it does not work as expected. Try debug the place where request is send and use placeholders to debug i wrote.

Offline

#6 2020-12-20 20:09:44

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

Re: RestApi POST method error

Also as i told don’t use special characters in url. Use body tab to send dedicated post parameters or just send as json payload.

Offline

#7 2020-12-20 20:19:57

evgen.galkin
New member
Registered: 2020-12-18
Posts: 4

Re: RestApi POST method error

The problem is sold by using tab "Body" in RestApi settings.
Thank you!

1608495582_2020-12-20_221807.jpg

Offline

Board footer