API error The response has unexpected status code (0)
Hi! I’m trying to connect with the API using Basic Auth but I’m getting an error 0. It’s not a caché problem, i’m deleting the caché frequently. The full response it’s:
array(1) { [“errors”]=> array(1) { [0]=> array(2) { [“code”]=> int(0) [“message”]=> string(56) "The response has unexpected status code (0). Response: " } } }
That’s my code:
And all good in the config:
Thanks!
UPDATE: The code return the same error in post/update but works!
It’s not working only for GET method, only returns the 0 error.
Any help? Thanks!
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
Hi,
Same error in here with the basic Contacts API get method. Any suggestions or tips with this issue?
Thank you!
In the meantime I figured out the problem. Is not Mautic specific but my local development environment. I run Mautic with Mamp and I tried to connect to the API endpoints from Docker container.
@jcpicot04 try to debug the Curl error message from here: lib/Auth/AbstractAuth.php, line 178 and you can see the error message.
Does anybody got its solution? Referring to @kovkor response, can you please expain as that file is not in Mautic 3.3.3 version
@faisalsarfraz
In my case I put this line temporarily into the file lib/Auth/AbstractAuth.php, line 178
echo 'Curl error: ' . curl_error($curl);
The error message was:
Curl error: Could not resolve host: xxxx