# Odd trouble with API calls

**URL:** https://forum.mautic.org/t/odd-trouble-with-api-calls/25512
**Category:** Product Support
**Tags:** mautic-4
**Created:** [September 26, 2022, 3:27pm UTC](https://forum.mautic.org/t/odd-trouble-with-api-calls/25512 "2022-09-26T15:27:14Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![entrepositive](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/entrepositive/32/9645_2.png) [@entrepositive](https://forum.mautic.org/u/entrepositive)
#### Post date: [September 26, 2022, 3:27pm UTC](https://forum.mautic.org/t/odd-trouble-with-api-calls/25512/1 "2022-09-26T15:27:14Z")

</div>

**Your software**  
My Mautic version is: v4.1.2  
My PHP version is: 7.4.30  
My Database type and version is: Mysql 8.0.30

**Your problem**

I have trouble connecting to the Mautic API. I’m no expert in API / http requests, but I can navigate my way around n8n to produce fruitful results. Correctly setting up oauth2 authorization with token requests and all that is currently outside the scope of my understanding. So that’s where I’m at.

✅ Currently I can set up a Mautic node in n8n (automation platform like Zapier, Integromat/Make) but that is limited in options… The credentials are correct and the system accepts the connection. These types of calls work: Get/Update Contact, Send segment email… But creating an email, and everything else within the scope of Mautic API is unavailable through the limitations of the node functions. So then a **http request** is my only option for that, which I cannot get to work.

❌ I tried to create a generic http request using “Credential type” for Mautic API, which is a simple log in for a unique User I created in Mautic strictly for the API access. The connection through the n8n system is accepted, showing a good connection. However, running a GET contacts/[ID] request returns:

```auto
{
"status": "rejected",
"reason": {
"context": {
},
"name": "NodeApiError",
"cause": {
"message": "connect ECONNREFUSED 127.0.0.1:80",
"name": "Error",
"stack": "Error: connect ECONNREFUSED 127.0.0.1:80 at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1187:16)",
"code": "ECONNREFUSED"
},
"timestamp": 1664205087653,
"message": "UNKNOWN ERROR - check the detailed error for more information",
"node": {
"parameters": {...}, // 10 keys
"name": "HTTP Request",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 2,
"position": [...], // 2 items
"credentials": {...} // 2 keys
},
"httpCode": "ECONNREFUSED",
"description": "connect ECONNREFUSED 127.0.0.1:80"
}
} 

```

❌ If I instead go with the “Credential type” Mautic _Oauth2_ API, once again the connection is accepted, but the GET contacts/[ID] call, returns exactly the same “ECONNREFUSED” error response. This means I cannot use all the wonderful capability of Mautic’s API like creating/editing emails, forms, landing pages, etc.

It is absolutely possible I do not have the Oauth2 settings correctly configured - maybe that’s a simple fix?

I’ve been having trouble with this for some time, and I’ve scoured YouTube, I’ve read through the Mautic docs and I’m here now because I can’t figure this out myself. If anyone has some wise council, I would really appreciate this!

**Steps I have tried to fix the problem:**

- Scoured [Mautic REST API docs](https://developer.mautic.org/?json#rest-api)
- Watched YouTube vids
- Read through related forum topics on Mautic, n8n, github, stackoverflow and other broader forums
- Exhausted all ideas I can come up with myself

Thanks!

EP

---

<div class="post-metadata">

### Author: ![joeyk](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/joeyk/32/11164_2.png) [@joeyk](https://forum.mautic.org/u/joeyk)
#### Post date: [September 26, 2022, 3:33pm UTC](https://forum.mautic.org/t/odd-trouble-with-api-calls/25512/2 "2022-09-26T15:33:35Z")

</div>

I’m using n8n with basic auth - and it works for me really well. Can’t say anything about basic auth.

---

<div class="post-metadata">

### Author: ![entrepositive](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/entrepositive/32/9645_2.png) [@entrepositive](https://forum.mautic.org/u/entrepositive)
#### Post date: [September 26, 2022, 3:57pm UTC](https://forum.mautic.org/t/odd-trouble-with-api-calls/25512/3 "2022-09-26T15:57:03Z")

</div>

Ah, update:

Now none of the connections are working at all with API. I don’t even know what changed since I posted this…but nothing is working, not even the reliable connection in Integromat - even that one now gives me 500 server error, with no connection.

Eh. This is super frustrating.

---

<div class="post-metadata">

### Author: ![entrepositive](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/entrepositive/32/9645_2.png) [@entrepositive](https://forum.mautic.org/u/entrepositive)
#### Post date: [September 26, 2022, 4:00pm UTC](https://forum.mautic.org/t/odd-trouble-with-api-calls/25512/4 "2022-09-26T16:00:01Z")

</div>

Thanks Joey, I’m not understanding exactly what you mean.

Is “Basic auth” the credentials-only connection? As in, not the “Oauth2” connection?

If so, that is the only one I have gotten to work within n8n, but also it only works with the Mautic node. That same connection was not working with an http request node.

But, as in my above comment, now nothing is working. 100% of my automation connections to Mautic are not functional at the moment. I’m running into more problems with Mautic these days than I am finding solutions…

---

<div class="post-metadata">

### Author: ![entrepositive](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/entrepositive/32/9645_2.png) [@entrepositive](https://forum.mautic.org/u/entrepositive)
#### Post date: [September 26, 2022, 4:04pm UTC](https://forum.mautic.org/t/odd-trouble-with-api-calls/25512/5 "2022-09-26T16:04:54Z")

</div>

This is my error now - even on existing automations that worked yesterday.

```auto
{
"context": {
},
"name": "NodeApiError",
"cause": {
"message": "500 - {"errors":[{"message":"Looks like I encountered an error (error #500). If I do it again, please report me to the system administrator!","code":500,"type":null}]}",
"name": "Error",
"stack": "Error: Request failed with status code 500 at createError (/usr/local/lib/node_modules/n8n/node_modules/axios/lib/core/createError.js:16:15) at settle (/usr/local/lib/node_modules/n8n/node_modules/axios/lib/core/settle.js:17:12) at IncomingMessage.handleStreamEnd (/usr/local/lib/node_modules/n8n/node_modules/axios/lib/adapters/http.js:269:11) at IncomingMessage.emit (node:events:539:35) at IncomingMessage.emit (node:domain:475:12) at endReadableNT (node:internal/streams/readable:1345:12) at processTicksAndRejections (node:internal/process/task_queues:83:21)"
},
"timestamp": 1664208223646,
"message": "The service was not able to process your request",
"node": {
"parameters": {
"authentication": "credentials",
"resource": "contact",
"operation": "update",
"contactId": "={{ $json["query"]["ContactID"] }}",
"jsonParameters": true,
"updateFields": {...}, // 1 keys
"options": {...} // 1 keys
},
"name": "Mautic",
"type": "n8n-nodes-base.mautic",
"typeVersion": 1,
"position": [
1040,
480
],
"credentials": {
"mauticApi": {...} // 2 keys
}
},
"httpCode": "500",
"description": "Looks like I encountered an error (error #500). If I do it again, please report me to the system administrator!"
} 

```

 ![Screen Shot 2022-09-26 at 12.08.15 PM](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/2X/4/4e3f888ab74422a5209384c47b068d8cff490eac.png)

---

<div class="post-metadata">

### Author: ![mzagmajster](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mzagmajster/32/687_2.png) [@mzagmajster](https://forum.mautic.org/u/mzagmajster)
#### Post date: [September 26, 2022, 5:29pm UTC](https://forum.mautic.org/t/odd-trouble-with-api-calls/25512/6 "2022-09-26T17:29:49Z")

</div>

What does mautic log says in /var/logs says, any details there?

---

<div class="post-metadata">

### Author: ![entrepositive](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/entrepositive/32/9645_2.png) [@entrepositive](https://forum.mautic.org/u/entrepositive)
#### Post date: [September 26, 2022, 7:18pm UTC](https://forum.mautic.org/t/odd-trouble-with-api-calls/25512/7 "2022-09-26T19:18:18Z")

</div>

This is from yesterday, 25 Sept:

```auto
[2022-09-25 19:48:07] mautic.NOTICE: PHP Notice - SessionHandler::gc(): ps_files_cleanup_dir: opendir(/var/lib/php/sessions) failed: Permission denied (13) - in file /var/www/html/mautic/vendor/symfony/http-foundation/Session/Storage/Handler/StrictSessionHandler.php - at line 106 {"maxlifetime":605000} []

```

This is from today:

```auto
[2022-09-25 20:55:55] mautic.ERROR: Symfony\Component\Filesystem\Exception\IOException: Cannot rename "/tmp/catalogue.en_US.ijbxPY_.phpLSWAg3" to "/var/www/html/mautic/var/cache/prod/translations/catalogue.en_US.ijbxPY_.php". - in file /var/www/html/mautic/vendor/symfony/filesystem/Filesystem.php - at line 290 [] []
[2022-09-25 21:30:08] mautic.WARNING: PHP Warning - unlink(/var/www/html/mautic/app/../var/cache/prod/translations/catalogue.en_US.ijbxPY_.php): Permission denied - in file /var/www/html/mautic/plugins/GautitClearCacheBundle/Controller/DefaultController.php - at line 66 {"dir":"/var/www/html/mautic/app/../var/cache/prod/translations","objects":[".","..","catalogue.en_US.ijbxPY_.php","catalogue.en_US.ijbxPY_.php.meta"],"object":"catalogue.en_US.ijbxPY_.php"} []
[2022-09-25 21:30:08] mautic.WARNING: PHP Warning - unlink(/var/www/html/mautic/app/../var/cache/prod/translations/catalogue.en_US.ijbxPY_.php.meta): Permission denied - in file /var/www/html/mautic/plugins/GautitClearCacheBundle/Controller/DefaultController.php - at line 66 {"dir":"/var/www/html/mautic/app/../var/cache/prod/translations","objects":[".","..","catalogue.en_US.ijbxPY_.php","catalogue.en_US.ijbxPY_.php.meta"],"object":"catalogue.en_US.ijbxPY_.php.meta"} []
[2022-09-25 21:30:08] mautic.WARNING: PHP Warning - rmdir(/var/www/html/mautic/app/../var/cache/prod/translations): Directory not empty - in file /var/www/html/mautic/plugins/GautitClearCacheBundle/Controller/DefaultController.php - at line 70 {"dir":"/var/www/html/mautic/app/../var/cache/prod/translations","objects":[".","..","catalogue.en_US.ijbxPY_.php","catalogue.en_US.ijbxPY_.php.meta"],"object":"catalogue.en_US.ijbxPY_.php.meta"} []
[2022-09-25 21:30:08] mautic.WARNING: PHP Warning - rmdir(/var/www/html/mautic/app/../var/cache/prod): Directory not empty - in file /var/www/html/mautic/plugins/GautitClearCacheBundle/Controller/DefaultController.php - at line 70 {"dir":"/var/www/html/mautic/app/../var/cache/prod","objects":[".","..","ContainerYFaTBDP","UrlGenerator.php","UrlGenerator.php.meta","UrlMatcher.php","UrlMatcher.php.meta","annotations.map","appAppKernelProdContainer.php","appAppKernelProdContainer.php.lock","appAppKernelProdContainer.php.meta","appAppKernelProdContainer.preload.php","data","doctrine","jms_serializer","middlewares.cache.php","pools","translations"],"object":"translations"} []
[2022-09-26 01:50:32] mautic.CRITICAL: Uncaught PHP Exception InvalidArgumentException: "The directory "/var/www/html/mautic/var/cache/prod/jms_serializer" is not writable." at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php line 48 {"exception":"[object] (InvalidArgumentException(code: 0): The directory \"/var/www/html/mautic/var/cache/prod/jms_serializer\" is not writable. at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php:48)"} []
[2022-09-26 01:50:33] mautic.CRITICAL: Uncaught PHP Exception InvalidArgumentException: "The directory "/var/www/html/mautic/var/cache/prod/jms_serializer" is not writable." at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php line 48 {"exception":"[object] (InvalidArgumentException(code: 0): The directory \"/var/www/html/mautic/var/cache/prod/jms_serializer\" is not writable. at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php:48)"} []
[2022-09-26 02:13:19] mautic.CRITICAL: Uncaught PHP Exception InvalidArgumentException: "The directory "/var/www/html/mautic/var/cache/prod/jms_serializer" is not writable." at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php line 48 {"exception":"[object] (InvalidArgumentException(code: 0): The directory \"/var/www/html/mautic/var/cache/prod/jms_serializer\" is not writable. at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php:48)"} []
[2022-09-26 02:39:28] mautic.CRITICAL: Uncaught PHP Exception InvalidArgumentException: "The directory "/var/www/html/mautic/var/cache/prod/jms_serializer" is not writable." at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php line 48 {"exception":"[object] (InvalidArgumentException(code: 0): The directory \"/var/www/html/mautic/var/cache/prod/jms_serializer\" is not writable. at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php:48)"} []
[2022-09-26 02:39:29] mautic.CRITICAL: Uncaught PHP Exception InvalidArgumentException: "The directory "/var/www/html/mautic/var/cache/prod/jms_serializer" is not writable." at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php line 48 {"exception":"[object] (InvalidArgumentException(code: 0): The directory \"/var/www/html/mautic/var/cache/prod/jms_serializer\" is not writable. at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php:48)"} []
[2022-09-26 02:39:58] mautic.CRITICAL: Uncaught PHP Exception InvalidArgumentException: "The directory "/var/www/html/mautic/var/cache/prod/jms_serializer" is not writable." at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php line 48 {"exception":"[object] (InvalidArgumentException(code: 0): The directory \"/var/www/html/mautic/var/cache/prod/jms_serializer\" is not writable. at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php:48)"} []
[2022-09-26 02:39:59] mautic.CRITICAL: Uncaught PHP Exception InvalidArgumentException: "The directory "/var/www/html/mautic/var/cache/prod/jms_serializer" is not writable." at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php line 48 {"exception":"[object] (InvalidArgumentException(code: 0): The directory \"/var/www/html/mautic/var/cache/prod/jms_serializer\" is not writable. at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php:48)"} []
[2022-09-26 02:42:36] mautic.CRITICAL: Uncaught PHP Exception InvalidArgumentException: "The directory "/var/www/html/mautic/var/cache/prod/jms_serializer" is not writable." at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php line 48 {"exception":"[object] (InvalidArgumentException(code: 0): The directory \"/var/www/html/mautic/var/cache/prod/jms_serializer\" is not writable. at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php:48)"} []
[2022-09-26 02:42:37] mautic.CRITICAL: Uncaught PHP Exception InvalidArgumentException: "The directory "/var/www/html/mautic/var/cache/prod/jms_serializer" is not writable." at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php line 48 {"exception":"[object] (InvalidArgumentException(code: 0): The directory \"/var/www/html/mautic/var/cache/prod/jms_serializer\" is not writable. at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php:48)"} []
[2022-09-26 02:42:56] mautic.CRITICAL: Uncaught PHP Exception InvalidArgumentException: "The directory "/var/www/html/mautic/var/cache/prod/jms_serializer" is not writable." at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php line 48 {"exception":"[object] (InvalidArgumentException(code: 0): The directory \"/var/www/html/mautic/var/cache/prod/jms_serializer\" is not writable. at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php:48)"} []
[2022-09-26 02:42:56] mautic.CRITICAL: Uncaught PHP Exception InvalidArgumentException: "The directory "/var/www/html/mautic/var/cache/prod/jms_serializer" is not writable." at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php line 48 {"exception":"[object] (InvalidArgumentException(code: 0): The directory \"/var/www/html/mautic/var/cache/prod/jms_serializer\" is not writable. at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php:48)"} []
[2022-09-26 02:43:08] mautic.CRITICAL: Uncaught PHP Exception InvalidArgumentException: "The directory "/var/www/html/mautic/var/cache/prod/jms_serializer" is not writable." at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php line 48 {"exception":"[object] (InvalidArgumentException(code: 0): The directory \"/var/www/html/mautic/var/cache/prod/jms_serializer\" is not writable. at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php:48)"} []
[2022-09-26 02:43:09] mautic.CRITICAL: Uncaught PHP Exception InvalidArgumentException: "The directory "/var/www/html/mautic/var/cache/prod/jms_serializer" is not writable." at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php line 48 {"exception":"[object] (InvalidArgumentException(code: 0): The directory \"/var/www/html/mautic/var/cache/prod/jms_serializer\" is not writable. at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php:48)"} []
[2022-09-26 02:43:44] mautic.CRITICAL: Uncaught PHP Exception InvalidArgumentException: "The directory "/var/www/html/mautic/var/cache/prod/jms_serializer" is not writable." at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php line 48 {"exception":"[object] (InvalidArgumentException(code: 0): The directory \"/var/www/html/mautic/var/cache/prod/jms_serializer\" is not writable. at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php:48)"} []
[2022-09-26 02:43:45] mautic.CRITICAL: Uncaught PHP Exception InvalidArgumentException: "The directory "/var/www/html/mautic/var/cache/prod/jms_serializer" is not writable." at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php line 48 {"exception":"[object] (InvalidArgumentException(code: 0): The directory \"/var/www/html/mautic/var/cache/prod/jms_serializer\" is not writable. at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php:48)"} []
[2022-09-26 02:43:53] mautic.CRITICAL: Uncaught PHP Exception InvalidArgumentException: "The directory "/var/www/html/mautic/var/cache/prod/jms_serializer" is not writable." at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php line 48 {"exception":"[object] (InvalidArgumentException(code: 0): The directory \"/var/www/html/mautic/var/cache/prod/jms_serializer\" is not writable. at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php:48)"} []
[2022-09-26 02:43:53] mautic.CRITICAL: Uncaught PHP Exception InvalidArgumentException: "The directory "/var/www/html/mautic/var/cache/prod/jms_serializer" is not writable." at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php line 48 {"exception":"[object] (InvalidArgumentException(code: 0): The directory \"/var/www/html/mautic/var/cache/prod/jms_serializer\" is not writable. at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php:48)"} []
[2022-09-26 02:44:46] mautic.CRITICAL: Uncaught PHP Exception InvalidArgumentException: "The directory "/var/www/html/mautic/var/cache/prod/jms_serializer" is not writable." at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php line 48 {"exception":"[object] (InvalidArgumentException(code: 0): The directory \"/var/www/html/mautic/var/cache/prod/jms_serializer\" is not writable. at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php:48)"} []
[2022-09-26 02:44:47] mautic.CRITICAL: Uncaught PHP Exception InvalidArgumentException: "The directory "/var/www/html/mautic/var/cache/prod/jms_serializer" is not writable." at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php line 48 {"exception":"[object] (InvalidArgumentException(code: 0): The directory \"/var/www/html/mautic/var/cache/prod/jms_serializer\" is not writable. at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php:48)"} []
[2022-09-26 02:45:36] mautic.CRITICAL: Uncaught PHP Exception InvalidArgumentException: "The directory "/var/www/html/mautic/var/cache/prod/jms_serializer" is not writable." at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php line 48 {"exception":"[object] (InvalidArgumentException(code: 0): The directory \"/var/www/html/mautic/var/cache/prod/jms_serializer\" is not writable. at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php:48)"} []
[2022-09-26 02:45:36] mautic.CRITICAL: Uncaught PHP Exception InvalidArgumentException: "The directory "/var/www/html/mautic/var/cache/prod/jms_serializer" is not writable." at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php line 48 {"exception":"[object] (InvalidArgumentException(code: 0): The directory \"/var/www/html/mautic/var/cache/prod/jms_serializer\" is not writable. at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php:48)"} []
[2022-09-26 02:45:46] mautic.CRITICAL: Uncaught PHP Exception InvalidArgumentException: "The directory "/var/www/html/mautic/var/cache/prod/jms_serializer" is not writable." at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php line 48 {"exception":"[object] (InvalidArgumentException(code: 0): The directory \"/var/www/html/mautic/var/cache/prod/jms_serializer\" is not writable. at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php:48)"} []
[2022-09-26 02:45:47] mautic.CRITICAL: Uncaught PHP Exception InvalidArgumentException: "The directory "/var/www/html/mautic/var/cache/prod/jms_serializer" is not writable." at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php line 48 {"exception":"[object] (InvalidArgumentException(code: 0): The directory \"/var/www/html/mautic/var/cache/prod/jms_serializer\" is not writable. at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php:48)"} []
[2022-09-26 02:46:43] mautic.CRITICAL: Uncaught PHP Exception InvalidArgumentException: "The directory "/var/www/html/mautic/var/cache/prod/jms_serializer" is not writable." at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php line 48 {"exception":"[object] (InvalidArgumentException(code: 0): The directory \"/var/www/html/mautic/var/cache/prod/jms_serializer\" is not writable. at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php:48)"} []
[2022-09-26 02:46:44] mautic.CRITICAL: Uncaught PHP Exception InvalidArgumentException: "The directory "/var/www/html/mautic/var/cache/prod/jms_serializer" is not writable." at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php line 48 {"exception":"[object] (InvalidArgumentException(code: 0): The directory \"/var/www/html/mautic/var/cache/prod/jms_serializer\" is not writable. at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php:48)"} []
[2022-09-26 02:51:07] mautic.CRITICAL: Uncaught PHP Exception InvalidArgumentException: "The directory "/var/www/html/mautic/var/cache/prod/jms_serializer" is not writable." at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php line 48 {"exception":"[object] (InvalidArgumentException(code: 0): The directory \"/var/www/html/mautic/var/cache/prod/jms_serializer\" is not writable. at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php:48)"} []
[2022-09-26 02:51:08] mautic.CRITICAL: Uncaught PHP Exception InvalidArgumentException: "The directory "/var/www/html/mautic/var/cache/prod/jms_serializer" is not writable." at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php line 48 {"exception":"[object] (InvalidArgumentException(code: 0): The directory \"/var/www/html/mautic/var/cache/prod/jms_serializer\" is not writable. at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php:48)"} []
[2022-09-26 02:51:28] mautic.CRITICAL: Uncaught PHP Exception InvalidArgumentException: "The directory "/var/www/html/mautic/var/cache/prod/jms_serializer" is not writable." at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php line 48 {"exception":"[object] (InvalidArgumentException(code: 0): The directory \"/var/www/html/mautic/var/cache/prod/jms_serializer\" is not writable. at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php:48)"} []
[2022-09-26 02:51:29] mautic.CRITICAL: Uncaught PHP Exception InvalidArgumentException: "The directory "/var/www/html/mautic/var/cache/prod/jms_serializer" is not writable." at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php line 48 {"exception":"[object] (InvalidArgumentException(code: 0): The directory \"/var/www/html/mautic/var/cache/prod/jms_serializer\" is not writable. at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php:48)"} []
[2022-09-26 02:52:28] mautic.CRITICAL: Uncaught PHP Exception InvalidArgumentException: "The directory "/var/www/html/mautic/var/cache/prod/jms_serializer" is not writable." at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php line 48 {"exception":"[object] (InvalidArgumentException(code: 0): The directory \"/var/www/html/mautic/var/cache/prod/jms_serializer\" is not writable. at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php:48)"} []
[2022-09-26 02:52:29] mautic.CRITICAL: Uncaught PHP Exception InvalidArgumentException: "The directory "/var/www/html/mautic/var/cache/prod/jms_serializer" is not writable." at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php line 48 {"exception":"[object] (InvalidArgumentException(code: 0): The directory \"/var/www/html/mautic/var/cache/prod/jms_serializer\" is not writable. at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php:48)"} []
[2022-09-26 13:10:23] mautic.NOTICE: PHP Notice - Trying to access array offset on value of type bool - in file /var/www/html/mautic/app/bundles/CoreBundle/Controller/ExceptionController.php - at line 120 {"request":"[object] (Symfony\\Component\\HttpFoundation\\Request: GET ///ext-js/app/common/zyFunction.js?v=220104164712 HTTP/1.1\r\nAccept: */*\r\nAccept-Encoding: gzip, deflate\r\nConnection: keep-alive\r\nHost: 104.237.2.228\r\nUser-Agent: python-requests/2.6.0 CPython/2.7.5 Linux/3.10.0-1160.76.1.el7.x86_64\r\nX-Php-Ob-Level: 1\r\n\r\n)","exception":"[object] (Symfony\\Component\\Debug\\Exception\\FlattenException: {})","logger":null,"class":"Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException","currentContent":"","layout":"Error","code":404,"anonymous":true,"baseTemplate":"MauticCoreBundle:Default:slim.html.php","templatePage":false,"template":"MauticCoreBundle:Error:404.html.php","templating":"[object] (Symfony\\Bundle\\FrameworkBundle\\Templating\\DelegatingEngine: {})","statusText":"Not Found","url":"///ext-js/app/common/zyFunction.js?v=220104164712","urlParts":false} []
[2022-09-26 14:57:50] mautic.CRITICAL: Uncaught PHP Exception InvalidArgumentException: "The directory "/var/www/html/mautic/var/cache/prod/jms_serializer" is not writable." at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php line 48 {"exception":"[object] (InvalidArgumentException(code: 0): The directory \"/var/www/html/mautic/var/cache/prod/jms_serializer\" is not writable. at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php:48)"} []
[2022-09-26 14:57:50] mautic.CRITICAL: Uncaught PHP Exception InvalidArgumentException: "The directory "/var/www/html/mautic/var/cache/prod/jms_serializer" is not writable." at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php line 48 {"exception":"[object] (InvalidArgumentException(code: 0): The directory \"/var/www/html/mautic/var/cache/prod/jms_serializer\" is not writable. at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php:48)"} []
[2022-09-26 15:45:47] mautic.CRITICAL: Uncaught PHP Exception InvalidArgumentException: "The directory "/var/www/html/mautic/var/cache/prod/jms_serializer" is not writable." at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php line 48 {"exception":"[object] (InvalidArgumentException(code: 0): The directory \"/var/www/html/mautic/var/cache/prod/jms_serializer\" is not writable. at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php:48)"} []
[2022-09-26 15:46:03] mautic.CRITICAL: Uncaught PHP Exception InvalidArgumentException: "The directory "/var/www/html/mautic/var/cache/prod/jms_serializer" is not writable." at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php line 48 {"exception":"[object] (InvalidArgumentException(code: 0): The directory \"/var/www/html/mautic/var/cache/prod/jms_serializer\" is not writable. at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php:48)"} []
[2022-09-26 15:46:24] mautic.CRITICAL: Uncaught PHP Exception InvalidArgumentException: "The directory "/var/www/html/mautic/var/cache/prod/jms_serializer" is not writable." at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php line 48 {"exception":"[object] (InvalidArgumentException(code: 0): The directory \"/var/www/html/mautic/var/cache/prod/jms_serializer\" is not writable. at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php:48)"} []
[2022-09-26 15:46:35] mautic.CRITICAL: Uncaught PHP Exception InvalidArgumentException: "The directory "/var/www/html/mautic/var/cache/prod/jms_serializer" is not writable." at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php line 48 {"exception":"[object] (InvalidArgumentException(code: 0): The directory \"/var/www/html/mautic/var/cache/prod/jms_serializer\" is not writable. at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php:48)"} []
[2022-09-26 15:54:29] mautic.CRITICAL: Uncaught PHP Exception InvalidArgumentException: "The directory "/var/www/html/mautic/var/cache/prod/jms_serializer" is not writable." at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php line 48 {"exception":"[object] (InvalidArgumentException(code: 0): The directory \"/var/www/html/mautic/var/cache/prod/jms_serializer\" is not writable. at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php:48)"} []
[2022-09-26 15:54:37] mautic.CRITICAL: Uncaught PHP Exception InvalidArgumentException: "The directory "/var/www/html/mautic/var/cache/prod/jms_serializer" is not writable." at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php line 48 {"exception":"[object] (InvalidArgumentException(code: 0): The directory \"/var/www/html/mautic/var/cache/prod/jms_serializer\" is not writable. at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php:48)"} []
[2022-09-26 15:54:40] mautic.CRITICAL: Uncaught PHP Exception InvalidArgumentException: "The directory "/var/www/html/mautic/var/cache/prod/jms_serializer" is not writable." at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php line 48 {"exception":"[object] (InvalidArgumentException(code: 0): The directory \"/var/www/html/mautic/var/cache/prod/jms_serializer\" is not writable. at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php:48)"} []
[2022-09-26 15:54:54] mautic.CRITICAL: Uncaught PHP Exception InvalidArgumentException: "The directory "/var/www/html/mautic/var/cache/prod/jms_serializer" is not writable." at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php line 48 {"exception":"[object] (InvalidArgumentException(code: 0): The directory \"/var/www/html/mautic/var/cache/prod/jms_serializer\" is not writable. at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php:48)"} []
[2022-09-26 15:55:09] mautic.CRITICAL: Uncaught PHP Exception InvalidArgumentException: "The directory "/var/www/html/mautic/var/cache/prod/jms_serializer" is not writable." at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php line 48 {"exception":"[object] (InvalidArgumentException(code: 0): The directory \"/var/www/html/mautic/var/cache/prod/jms_serializer\" is not writable. at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php:48)"} []
[2022-09-26 16:03:42] mautic.CRITICAL: Uncaught PHP Exception InvalidArgumentException: "The directory "/var/www/html/mautic/var/cache/prod/jms_serializer" is not writable." at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php line 48 {"exception":"[object] (InvalidArgumentException(code: 0): The directory \"/var/www/html/mautic/var/cache/prod/jms_serializer\" is not writable. at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php:48)"} []
[2022-09-26 16:03:43] mautic.CRITICAL: Uncaught PHP Exception InvalidArgumentException: "The directory "/var/www/html/mautic/var/cache/prod/jms_serializer" is not writable." at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php line 48 {"exception":"[object] (InvalidArgumentException(code: 0): The directory \"/var/www/html/mautic/var/cache/prod/jms_serializer\" is not writable. at /var/www/html/mautic/vendor/jms/metadata/src/Cache/FileCache.php:48)"} []

```

---

<div class="post-metadata">

### Author: ![mzagmajster](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mzagmajster/32/687_2.png) [@mzagmajster](https://forum.mautic.org/u/mzagmajster)
#### Post date: [September 26, 2022, 7:46pm UTC](https://forum.mautic.org/t/odd-trouble-with-api-calls/25512/8 "2022-09-26T19:46:59Z")

</div>

Hi,

based on error you have posted I believe the issue is in permissions. Every time you deploy something/clear the cache or manipulate mautic files on the server you should run the permissions script I have given you otherwise you might experience difficulties with mautic.

So var/cache and everything in it must be writable by web server user (usually www-data).

Please give another test to the integration and see if it works.

Hope it helps.  
Regards, M.

---

<div class="post-metadata">

### Author: ![entrepositive](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/entrepositive/32/9645_2.png) [@entrepositive](https://forum.mautic.org/u/entrepositive)
#### Post date: [September 26, 2022, 8:30pm UTC](https://forum.mautic.org/t/odd-trouble-with-api-calls/25512/9 "2022-09-26T20:30:55Z")

</div>

WORKS!!! @mzagmajster you are a wizard.

I need to figure out how to run that script. I guess it’s at the command line.

---

<div class="post-metadata">

### Author: ![mzagmajster](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mzagmajster/32/687_2.png) [@mzagmajster](https://forum.mautic.org/u/mzagmajster)
#### Post date: [September 26, 2022, 8:41pm UTC](https://forum.mautic.org/t/odd-trouble-with-api-calls/25512/10 "2022-09-26T20:41:16Z")

</div>

Yes, you use terminal.

You login to your server with:

```auto
ssh <user>@<ip>
<path-to-script>

```

Press enter and you are done.

---

<div class="post-metadata">

### Author: ![pfernandes](https://avatars.discourse-cdn.com/v4/letter/p/e47774/32.png) [@pfernandes](https://forum.mautic.org/u/pfernandes)
#### Post date: [February 14, 2023, 1:01pm UTC](https://forum.mautic.org/t/odd-trouble-with-api-calls/25512/11 "2023-02-14T13:01:19Z")

</div>

Hi!  
I’ve the same problem, but I can’t figure out a solution. Every time I clear cache, the oAuth works only once ☹ Then, it goes back to error 500, both on n8n and Zapier.  
Can you help me?  
Thanks a lot.

“The directory “/home/…/public\_html/…/…/var/cache/prod/jms\_serializer” is not writable.”

---

<div class="post-metadata">

### Author: ![joeyk](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/joeyk/32/11164_2.png) [@joeyk](https://forum.mautic.org/u/joeyk)
#### Post date: [February 14, 2023, 4:15pm UTC](https://forum.mautic.org/t/odd-trouble-with-api-calls/25512/12 "2023-02-14T16:15:15Z")

</div>

Hi, what if you make it writable? 🙂

---

<div class="post-metadata">

### Author: ![entrepositive](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/entrepositive/32/9645_2.png) [@entrepositive](https://forum.mautic.org/u/entrepositive)
#### Post date: [February 16, 2023, 8:02pm UTC](https://forum.mautic.org/t/odd-trouble-with-api-calls/25512/13 "2023-02-16T20:02:10Z")

</div>

File/directory permissions are extremely important for Mautic functionality (and for security, on the other side). But as I’ve come to realize, different Mautic installs can result in different file permission settings. How/why that happens is simply beyond my current understanding. I just know it’s critical they are set correctly.

EP

---

<div class="post-metadata">

### Author: ![pfernandes](https://avatars.discourse-cdn.com/v4/letter/p/e47774/32.png) [@pfernandes](https://forum.mautic.org/u/pfernandes)
#### Post date: [February 16, 2023, 9:28pm UTC](https://forum.mautic.org/t/odd-trouble-with-api-calls/25512/14 "2023-02-16T21:28:22Z")

</div>

Hi @joeyk! of course, I’ve tried to do that 😃

I’ve also tried to completely delete cache folder to force mautic to rebuild cache folder again; and so on…

But, today something come to my mind, and I’ve tried to delete “tmp” folder (since I had a similar problem related with “unsubscribing” not working, and the problem was in “tmp” folder), and guess what… everything is working normal now… API connecting with Zapier / N8N 🤣

The log was referring permissions in cache folder, but probably it was nothing to do with that… 🙂

Well, strange thinks appends to strange people!

I hope it will help somebody with the same issue…

---

<div class="post-metadata">

### Author: ![joeyk](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/joeyk/32/11164_2.png) [@joeyk](https://forum.mautic.org/u/joeyk)
#### Post date: [February 17, 2023, 4:23pm UTC](https://forum.mautic.org/t/odd-trouble-with-api-calls/25512/15 "2023-02-17T16:23:29Z")

</div>

Hi, In my opinion the best way to clear cache is via command:

`php /var/www/html/mautic/bin/console cache:clear`

Or if you are sudo, and the webserver owner is www-data, then:  
`sudo -u www-data php /var/www/html/mautic/bin/console cache:clear`

---

<div class="post-metadata">

### Author: ![gathh](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/gathh/32/6515_2.png) [@gathh](https://forum.mautic.org/u/gathh)
#### Post date: [February 12, 2024, 3:03am UTC](https://forum.mautic.org/t/odd-trouble-with-api-calls/25512/16 "2024-02-12T03:03:38Z")

</div>

> [@mzagmajster](#):
>
> run the permissions script I have given you

Where can I find this permissions script please? Thank you.

---

<div class="post-metadata">

### Author: ![cfloinc](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/cfloinc/32/11036_2.png) [@cfloinc](https://forum.mautic.org/u/cfloinc)
#### Post date: [February 29, 2024, 5:36pm UTC](https://forum.mautic.org/t/odd-trouble-with-api-calls/25512/17 "2024-02-29T17:36:15Z")

</div>

yes @mzagmajster I too am looking for the permissions script  
(also running into permissions errors that are causing issues with API)

---

<div class="post-metadata">

### Author: ![mzagmajster](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mzagmajster/32/687_2.png) [@mzagmajster](https://forum.mautic.org/u/mzagmajster)
#### Post date: [March 1, 2024, 5:12pm UTC](https://forum.mautic.org/t/odd-trouble-with-api-calls/25512/18 "2024-03-01T17:12:01Z")

</div>

Drop me a DM, please

---

<div class="post-metadata">

### Author: ![entrepositive](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/entrepositive/32/9645_2.png) [@entrepositive](https://forum.mautic.org/u/entrepositive)
#### Post date: [March 28, 2024, 6:55pm UTC](https://forum.mautic.org/t/odd-trouble-with-api-calls/25512/19 "2024-03-28T18:55:57Z")

</div>

@mzagmajster 👈 this guy is a genius, trust him.

---

<div class="post-metadata">

### Author: ![jonathan-wavery](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/jonathan-wavery/32/13823_2.png) [@jonathan-wavery](https://forum.mautic.org/u/jonathan-wavery)
#### Post date: [March 19, 2025, 10:37am UTC](https://forum.mautic.org/t/odd-trouble-with-api-calls/25512/20 "2025-03-19T10:37:41Z")

</div>

For anyone else looking for the script, this is what worked for me:

```auto
sudo chown -R www-data:www-data /var/www/[MAUTIC DIRECTORY]/var/cache
sudo chmod -R 775 /var/www/[MAUTIC DIRECTORY]/var/cache

```
