Mautic Community Forums

Segment API 404 Problem

Your software
My Mautic version is:2.16.2
My PHP version is:7.2

I’m developing some API calls from Joomla to Mautic,
I’m testing all the calls with Postman that produce the php code for me.
With this method I was able to create, delete, edit, search contact; triggering points etc… etc…

In Postman add a contact to a segment works perfectly but when I export the php curl code and I test it I receive a 404 error. But the code is straightforward.

I’ve cleaned the cache as suggested.

I’ve added a buffer to understand better what’s is going on, what I dont’ understand is “Mark bundle as not supporting multiuse”, and the 404 error.

Can someone help me to solve / understand the problem?
Thanks.

The code:
$curl = curl_init();

curl_setopt_array($curl, array(
CURLOPT_URL => “https://www.mail.istitutomedicinanaturale.it/api/segments/1/contact/2499/add”,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => “”,
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => “POST”,
CURLOPT_HTTPHEADER => array(
“Authorization: Basic XXXXXXXXXX=”,
“Cookie: mautic_device_id=cd94dcnjnlg6dk5meoyt7uc; mautic_session_id=cd94dcnjnlg6dk5meoyt7uc; cd94dcnjnlg6dk5meoyt7uc=23708; 35e9fb9389ff18d92ea40662974709c9=73568dc6147610fcef78d271f3733226”
),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

The buffer output:
string(1458) "* Trying 185.81.4.186:443…
Connected to www.mail.istitutomedicinanaturale.it (185.81.4.186) port 443 (#0)
ALPN, offering http/1.1
successfully set certificate verify locations:
CAfile: /etc/pki/tls/certs/ca-bundle.crt
CApath: none
SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384* ALPN, server accepted to use http/1.1
Server certificate:
subject: CN=mail.istitutomedicinanaturale.it
start date: May 1 11:52:00 2020 GMT
expire date: Jul 30 11:52:00 2020 GMT
subjectAltName: host “www.mail.istitutomedicinanaturale.it” matched cert’s “www.mail.istitutomedicinanaturale.it”
issuer: C=US; O=Let’s Encrypt; CN=Let’s Encrypt Authority X3
SSL certificate verify ok.
POST /api/segments/1/contact/2499/add HTTP/1.1
Host: www.mail.istitutomedicinanaturale.it
Accept: /
Accept-Encoding: deflate, gzip, br
Authorization: Basic XXXXXXXXXX=
Cookie: mautic_device_id=cd94dcnjnlg6dk5meoyt7uc; mautic_session_id=cd94dcnjnlg6dk5meoyt7uc; cd94dcnjnlg6dk5meoyt7uc=23708; 35e9fb9389ff18d92ea40662974709c9=73568dc6147610fcef78d271f3733226

Mark bundle as not supporting multiuse
HTTP/1.1 404 Not Found
Date: Fri, 22 May 2020 12:11:03 GMT
Server: Apache
Cache-Control: no-cache
Vary: Authorization
Upgrade: h2,h2c
Connection: Upgrade
Transfer-Encoding: chunked
Content-Type: application/json

Connection #0 to host www.mail.istitutomedicinanaturale.it left intact

Solved:
In my case the HTTP_VERSION have to be 2.0.
change from:
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1
to:
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_2_0

Glad to hear you found the solution - thanks for taking the time to report back!

I hope that the post is “solved” if not, please tell me how mark the post as solved

Yes, it is marked as solved :tada: