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:
{
"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
- 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