404 Message for API Call: PATCH api/contacts/[contact id]/EDIT

Your software
My Mautic version is: v4.4.1
My PHP version is: 8.0.28
My Database type and version is: 8.0.33

Your problem
My problem is: I’m authenticated properly using the API, but the API call to update users is returning a 404 error.

Steps I have tried to fix the problem: I have cleared the cache both deleting the folders and by using mautic:cache:clear. In both cases, the API continues to return 404 errors.

Is it possible that the API request is failing because the URL has “EDIT” in uppercase (all caps)? I’m not a developer, but I can see the logs in the software that is connecting to the API and I see this is the only API call that uses uppercase.

Could you also test with lower case?

We have a similar situation, where one instance works with patch, another doesn’t. Its on the same server hardware and webserver. Something is different in the setup. Our partner will probably setup the installation as a fresh tomorrow. There were some troubles with the composer based installation and changed host names afterwards - maybe this is the culprit…

I’ve tested with lowercase. I now get a 200 response for the API call, but my goal with this API call is to update the email address of the user in the DB. After making the API call, the email address is not updated in the database.

The old email address remains.

So, I think this is a bug. Perhaps a method other than PATCH should be used? POST?

To edit a contact and return a 404 if the contact is not found:

PATCH /contacts/ID/edit

To edit a contact and create a new one if the contact is not found:

PUT /contacts/ID/edit

This will create a new contact however which is not what you want.

Are you using the correct contact ID ?

What is your payload looking like?

Yes, I’ve verified the contact ID is correct and I get a 200 response. From what I can tell the API request sends the firstname, lastname, and email address to Mautic using PATCH. However, none of the values are actually updated in Mautic, despite the 200 response.

Here’s the output from the log:

Request:

<invoice-log-item type="outgoing-request">
 <method>PATCH</method>
 <url>https://marketing.marketdata.app/marketdata/api/contacts/2944/edit</url>
 <headers>
  <header name="user-agent">aMember PRO/6.3.19 (https://www.amember.com)</header>
  <header name="content-type">application/x-www-form-urlencoded</header>
 </headers>
 <params>
  <p name="firstname">Mautic</p>
  <p name="lastname">Update</p>
  <p name="email">newemail@gmail.com</p>
 </params>
</invoice-log-item>

Response:

<invoice-log-item type="outgoing-request-response">
 <status code="200" reason="OK"/>
 <headers>
  <header name="date">Tue, 30 May 2023 17:11:42 GMT</header>
  <header name="content-type">application/json</header>
  <header name="transfer-encoding">chunked</header>
  <header name="connection">keep-alive</header>
  <header name="mautic-version">4.4.1</header>
  <header name="cache-control">max-age=0, must-revalidate, private</header>
  <header name="expires">Tue, 30 May 2023 17:11:42 GMT</header>
  <header name="vary">Authorization</header>
  <header name="cf-cache-status">DYNAMIC</header>
  <header name="report-to">{"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=BxmJGij8x6%2B77tpDRmX%2Bp2yuqEOaGH0h6cNtNkJ75B0Gvu8jmpoTLVC4wdfzkpTALw2ibXErZ3Q4%2BFwi8SnJKzQMPQaVkpD0GrElulplkpf8hyhE9uLdQdYD1Je5dJrvD6r0lGsG%2FfPW%2FnHw5%2F0Mfh%2FMRFTU9Tw%3D"}],"group":"cf-nel","max_age":604800}</header>
  <header name="nel">{"success_fraction":0,"report_to":"cf-nel","max_age":604800}</header>
  <header name="server">cloudflare</header>
  <header name="cf-ray">7cf898fefdb74865-DFW</header>
  <header name="content-encoding">br</header>
  <header name="alt-svc">h3=":443"; ma=86400</header>
 </headers>
 <body><![CDATA[{"contact":{"isPublished":true,"dateAdded":"2021-06-28T19:49:31+00:00","dateModified":"2023-05-05T17:24:42+00:00","createdBy":null,"createdByUser":null,"modifiedBy":3,"modifiedByUser":"amember amember","id":2944,"points":3959,"color":null,"fields":{"core":{"username":{"id":"46","label":"Username","alias":"username","type":"text","group":"core","object":"lead","is_fixed":"0","properties":"a:0:{}","default_value":null,"value":"redacted","normalizedValue":"redacted"},"country1":{"id":"44","label":"ISO Country","alias":"country1","type":"text","group":"core","object":"lead","is_fixed":"0","properties":"a:0:{}","default_value":null,"value":"AR","normalizedValue":"AR"},"title":{"id":"1","label":"Title","alias":"title","type":"lookup","group":"core","object":"lead","is_fixed":"1","properties":"a:1:{s:4:\"list\";a:3:{i:0;s:2:\"Mr\";i:1;s:3:\"Mrs\";i:2;s:4:\"Miss\";}}","default_value":null,"value":"redacted","normalizedValue":"redacted"},"dateapi":{"id":"48","label":"Last API Usage Date","alias":"dateapi","type":"date","group":"core","object":"lead","is_fixed":"0","properties":"a:0:{}","default_value":null,"value":"2023-03-21","normalizedValue":"2023-03-21"},"daysapi":{"id":"51","label":"Days API Used","alias":"daysapi","type":"number","group":"core","object":"lead","is_fixed":"0","properties":"a:2:{s:9:\"roundmode\";s:1:\"3\";s:5:\"scale\";s:1:\"0\";}","default_value":null,"value":null,"normalizedValue":null},"usageapi":{"id":"50","label":"API Usage","alias":"usageapi","type":"number","group":"core","object":"lead","is_fixed":"0","properties":"a:2:{s:9:\"roundmode\";s:1:\"6\";s:5:\"scale\";s:1:\"0\";}","default_value":null,"value":null,"normalizedValue":null},"firstname":{"id":"2","label":"First Name","alias":"firstname","type":"text","group":"core","object":"lead","is_fixed":"1","properties":"a:0:{}","default_value":null,"value":"redacted","normalizedValue":"redacted"},"lastname":{"id":"3","label":"Last Name","alias":"lastname","type":"text","group":"core","object":"lead","is_fixed":"1","properties":"a:0:{}","default_value":null,"value":"redacted","normalizedValue":"redacted"},"autologincode":{"id":"47","label":"Auto Login Code","alias":"autologincode","type":"text","group":"core","object":"lead","is_fixed":"0","properties":"a:0:{}","default_value":null,"value":"UZq0HP5NrSSPlctXmSmH","normalizedValue":"UZq0HP5NrSSPlctXmSmH"},"email":{"id":"6","label":"Email","alias":"email","type":"email","group":"core","object":"lead","is_fixed":"1","properties":"a:0:{}","default_value":null,"value":"redacted@gmail.com","normalizedValue":"redacted@gmail.com"},"mobile":{"id":"7","label":"Mobile","alias":"mobile","type":"tel","group":"core","object":"lead","is_fixed":"1","properties":"a:0:{}","default_value":null,"value":null,"normalizedValue":null},"phone":{"id":"8","label":"Phone","alias":"phone","type":"tel","group":"core","object":"lead","is_fixed":"1","properties":"a:0:{}","default_value":null,"value":"+541131306209","normalizedValue":"+541131306209"},"points":{"id":"9","label":"Points","alias":"points","type":"number","group":"core","object":"lead","is_fixed":"1","properties":"a:0:{}","default_value":"0","value":3959,"normalizedValue":3959},"address1":{"id":"11","label":"Address Line 1","alias":"address1","type":"text","group":"core","object":"lead","is_fixed":"1","properties":"a:0:{}","default_value":null,"value":null,"normalizedValue":null},"address2":{"id":"12","label":"Address Line 2","alias":"address2","type":"text","group":"core","object":"lead","is_fixed":"1","properties":"a:0:{}","default_value":null,"value":null,"normalizedValue":null},"city":{"id":"13","label":"City","alias":"city","type":"text","group":"core","object":"lead","is_fixed":"1","properties":"a:0:{}","default_value":null,"value":"Belen de Escobar","normalizedValue":"Belen de Escobar"},"state":{"id":"14","label":"State","alias":"state","type":"region","group":"core","object":"lead","is_fixed":"1","properties":"a:0:{}","default_value":null,"value":"Buenos Aires","normalizedValue":"Buenos Aires"},"zipcode":{"id":"15","label":"Zip Code","alias":"zipcode","type":"text","group":"core","object":"lead","is_fixed":"1","properties":"a:0:{}","default_value":null,"value":null,"normalizedValue":null},"country":{"id":"16","label":"Country","alias":"country","type":"country","group":"core","object":"lead","is_fixed":"1","properties":"a:0:{}","default_value":null,"value":"Argentina","normalizedValue":"Argentina"},"preferred_locale":{"id":"17","label":"Preferred Locale","alias":"preferred_locale","type":"locale","group":"core","object":"lead","is_fixed":"1","properties":"a:0:{}","default_value":null,"value":null,"normalizedValue":null},"timezone":{"id":"18","label":"Preferred Timezone","alias":"timezone","type":"timezone","group":"core","object":"lead","is_fixed":"1","properties":"a:0:{}","default_value":null,"value":"America\/Sao_Paulo","normalizedValue":"America\/Sao_Paulo"},"last_active":{"id":"19","label":"Date Last Active","alias":"last_active","type":"datetime","group":"core","object":"lead","is_fixed":"1","properties":"a:0:{}","default_value":null,"value":"2023-05-05 17:25:20","normalizedValue":"2023-05-05 17:25:20"},"attribution_date":{"id":"20","label":"Attribution Date","alias":"attribution_date","type":"datetime","group":"core","object":"lead","is_fixed":"1","properties":"a:0:{}","default_value":null,"value":null,"normalizedValue":null},"attribution":{"id":"21","label":"Attribution","alias":"attribution","type":"number","group":"core","object":"lead","is_fixed":"1","properties":"a:2:{s:9:\"roundmode\";i:4;s:5:\"scale\";i:2;}","default_value":null,"value":null,"normalizedValue":null},"website":{"id":"22","label":"Website","alias":"website","type":"url","group":"core","object":"lead","is_fixed":"0","properties":"a:0:{}","default_value":null,"value":null,"normalizedValue":null}},"personal":{"token":{"id":"45","label":"Token","alias":"token","type":"text","group":"personal","object":"lead","is_fixed":"0","properties":"a:0:{}","default_value":null,"value":null,"normalizedValue":null}},"social":{"facebook":{"id":"23","label":"Facebook","alias":"facebook","type":"text","group":"social","object":"lead","is_fixed":"0","properties":"a:0:{}","default_value":null,"value":null,"normalizedValue":null},"instagram":{"id":"25","label":"Instagram","alias":"instagram","type":"text","group":"social","object":"lead","is_fixed":"0","properties":"a:0:{}","default_value":null,"value":null,"normalizedValue":null},"linkedin":{"id":"26","label":"LinkedIn","alias":"linkedin","type":"text","group":"social","object":"lead","is_fixed":"0","properties":"a:0:{}","default_value":null,"value":null,"normalizedValue":null},"skype":{"id":"27","label":"Skype","alias":"skype","type":"text","group":"social","object":"lead","is_fixed":"0","properties":"a:0:{}","default_value":null,"value":null,"normalizedValue":null},"twitter":{"id":"28","label":"Twitter","alias":"twitter","type":"text","group":"social","object":"lead","is_fixed":"0","properties":"a:0:{}","default_value":null,"value":null,"normalizedValue":null}},"professional":[],"all":{"id":"2944","username":"redacted","country1":"AR","title":"redacted","dateapi":"2023-03-21","daysapi":null,"usageapi":null,"firstname":"redacted","lastname":"redacted","autologincode":"redacted","email":"redacted@gmail.com","mobile":null,"phone":"+redacted","points":3959,"address1":null,"address2":null,"city":"Belen de Escobar","state":"Buenos Aires","zipcode":null,"country":"Argentina","preferred_locale":null,"timezone":"America\/Sao_Paulo","last_active":"2023-05-05 17:25:20","attribution_date":null,"attribution":null,"website":null,"token":null,"facebook":null,"instagram":null,"linkedin":null,"skype":null,"twitter":null}},"lastActive":"2023-05-05T17:25:20+00:00","owner":null,"ipAddresses":[{"ipAddress":"2800:810:45c:201:cc39:ad4e:f0e7:a634","id":4009,"ipDetails":{"city":"Los Polvorines","region":"Buenos Aires","zipcode":null,"country":"Argentina","latitude":-34.507599999999996498445398174226284027099609375,"longitude":-58.6863000000000027966962079517543315887451171875,"isp":"","organization":"","timezone":"America\/Argentina\/Buenos_Aires","extra":""}},{"ipAddress":"181.14.245.226","id":13382,"ipDetails":{"city":"Benavidez","region":"Buenos Aires","zipcode":null,"country":"Argentina","latitude":-34.4097000000000008412825991399586200714111328125,"longitude":-58.71430000000000148929757415316998958587646484375,"isp":"","organization":"","timezone":"America\/Argentina\/Buenos_Aires","extra":""}},{"ipAddress":"181.98.67.7","id":14083,"ipDetails":{"city":"","region":"","zipcode":"","country":"","latitude":"","longitude":"","isp":"","organization":"","timezone":"","extra":""}},{"ipAddress":"103.174.206.46","id":16532,"ipDetails":{"city":"Gujranwala","region":"Punjab","zipcode":null,"country":"Pakistan","latitude":32.1537000000000006139089236967265605926513671875,"longitude":74.21989999999999554347596131265163421630859375,"isp":"","organization":"","timezone":"Asia\/Karachi","extra":""}},{"ipAddress":"179.43.101.25","id":22914,"ipDetails":{"city":"Belen de Escobar","region":"Buenos Aires","zipcode":null,"country":"Argentina","latitude":-34.34530000000000171667124959640204906463623046875,"longitude":-58.82300000000000039790393202565610408782958984375,"isp":"","organization":"","timezone":"America\/Argentina\/Buenos_Aires","extra":""}},{"ipAddress":"181.93.210.50","id":16672,"ipDetails":{"city":"Tigre","region":"Buenos Aires","zipcode":null,"country":"Argentina","latitude":-34.41760000000000019326762412674725055694580078125,"longitude":-58.59020000000000294448909698985517024993896484375,"isp":"","organization":"","timezone":"America\/Argentina\/Buenos_Aires","extra":""}},{"ipAddress":"181.93.208.180","id":17606,"ipDetails":{"city":"Tigre","region":"Buenos Aires","zipcode":null,"country":"Argentina","latitude":-34.41760000000000019326762412674725055694580078125,"longitude":-58.59020000000000294448909698985517024993896484375,"isp":"","organization":"","timezone":"America\/Argentina\/Buenos_Aires","extra":""}},{"ipAddress":"181.98.66.26","id":18191,"ipDetails":{"city":"Buenos Aires","region":"Buenos Aires F.D.","zipcode":null,"country":"Argentina","latitude":-34.60220000000000339923644787631928920745849609375,"longitude":-58.3845000000000027284841053187847137451171875,"isp":"","organization":"","timezone":"America\/Argentina\/Buenos_Aires","extra":""}},{"ipAddress":"181.93.208.187","id":20958,"ipDetails":{"city":"Nordelta","region":"Buenos Aires","zipcode":null,"country":"Argentina","latitude":-34.41420000000000101181285572238266468048095703125,"longitude":-58.64959999999999951114659779705107212066650390625,"isp":"","organization":"","timezone":"America\/Argentina\/Buenos_Aires","extra":""}},{"ipAddress":"181.98.64.133","id":23413,"ipDetails":{"city":"Tigre","region":"Buenos Aires","zipcode":null,"country":"Argentina","latitude":-34.4260000000000019326762412674725055694580078125,"longitude":-58.579599999999999226929503493010997772216796875,"isp":"","organization":"","timezone":"America\/Argentina\/Buenos_Aires","extra":""}},{"ipAddress":"181.98.64.11","id":23918,"ipDetails":{"city":"Tigre","region":"Buenos Aires","zipcode":null,"country":"Argentina","latitude":-34.4260000000000019326762412674725055694580078125,"longitude":-58.579599999999999226929503493010997772216796875,"isp":"","organization":"","timezone":"America\/Argentina\/Buenos_Aires","extra":""}},{"ipAddress":"181.98.65.20","id":24801,"ipDetails":{"city":"Nordelta","region":"Buenos Aires","zipcode":null,"country":"Argentina","latitude":-34.41420000000000101181285572238266468048095703125,"longitude":-58.64959999999999951114659779705107212066650390625,"isp":"","organization":"","timezone":"America\/Argentina\/Buenos_Aires","extra":""}},{"ipAddress":"181.98.66.51","id":25089,"ipDetails":{"city":"Nordelta","region":"Buenos Aires","zipcode":null,"country":"Argentina","latitude":-34.41420000000000101181285572238266468048095703125,"longitude":-58.64959999999999951114659779705107212066650390625,"isp":"","organization":"","timezone":"America\/Argentina\/Buenos_Aires","extra":""}},{"ipAddress":"179.43.100.243","id":26103,"ipDetails":{"city":"Belen de Escobar","region":"Buenos Aires","zipcode":null,"country":"Argentina","latitude":-34.34599999999999653255144949071109294891357421875,"longitude":-58.794499999999999317878973670303821563720703125,"isp":"","organization":"","timezone":"America\/Argentina\/Buenos_Aires","extra":""}},{"ipAddress":"181.93.208.121","id":73292,"ipDetails":{"city":"Nordelta","region":"Buenos Aires","zipcode":null,"country":"Argentina","latitude":-34.41420000000000101181285572238266468048095703125,"longitude":-58.64959999999999951114659779705107212066650390625,"isp":"","organization":"","timezone":"America\/Argentina\/Buenos_Aires","extra":""}}],"tags":[{"id":6,"tag":"add-on installed","description":null},{"id":5,"tag":"api","description":null},{"id":4,"tag":"google sheets","description":null},{"id":9,"tag":"intraday","description":null},{"id":3,"tag":"options","description":null},{"id":12,"tag":"paid","description":null},{"id":10,"tag":"stocks","description":null},{"id":11,"tag":"trial","description":null}],"utmtags":[{"id":706,"query":{"formId":"1"},"referer":"https:\/\/www.marketdata.app\/","remoteHost":"www.marketdata.app","url":"\/mautic\/form\/submit?formId=1","userAgent":null,"utmCampaign":null,"utmContent":null,"utmMedium":null,"utmSource":null,"utmTerm":null},{"id":2919,"query":{"utm_medium":"company_profile","utm_source":"trustpilot","utm_campaign":"domain_click","page_title":"Get Data Anywhere \u00b7 Market Data","page_language":"en-US","preferred_locale":"en_US","page_referrer":"","page_url":"https:\/\/www.marketdata.app\/?utm_medium=company_profile&utm_source=trustpilot&utm_campaign=domain_click","counter":"0","timezone_offset":"180","resolution":"1792x1120","platform":"MacOS","do_not_track":"false","timezone":"America\/Buenos_Aires","mautic_device_id":"7al5zr6shcrplf17bnhifys"},"referer":"https:\/\/www.marketdata.app\/","remoteHost":null,"url":"https:\/\/www.marketdata.app\/?utm_medium=company_profile&utm_source=trustpilot&utm_campaign=domain_click","userAgent":"Mozilla\/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/100.0.4896.88 Safari\/537.36","utmCampaign":"domain_click","utmContent":null,"utmMedium":"company_profile","utmSource":"trustpilot","utmTerm":null}],"stage":null,"dateIdentified":"2021-06-28T19:51:58+00:00","preferredProfileImage":"gravatar","doNotContact":[],"frequencyRules":[]}}]]></body>

Bumping this after two weeks. Anyone have any clue what may be going on? Very strange now… getting a 200 response on the API call, but the contact is not getting updated.

Hi @growthlab
I just tried it 2 minutes ago with that data:

image

Worked fine, the response confirmed it - also the Mautic Backend shows correct data. I used the JSON way, not PHP… if that makes a difference. Could you try to only send the email and see if that works?

How do you generate the API call?

(By the way, that screenshot is from our tapeapp.com integration, which we will introduce to the community at the Mautic Global Conference at day 1: Schedule ► The home of the official Mautic Conferences - will you be there?)