I’m new around here and just started my learning with N8N.
I would really appreciate it if you could help me with an integration I’m trying to do with Mautic and a customer’s CRM.
I already connected Mautic to the N8N. Now, I need to integrate each lead captured in Mautic forms into this CRM, whose API documentation has the following instructions:
"The APIs use REST (Representational State Transfer) technology, based on the HTTP protocol.
The requests must be made through the HTTP POST method and to send the content use the JSON notation
This method imports Leads generated through external platforms. The following examples have the basic Lead parameters.
Hi @Edney, welcome to the community! n8n offers the HTTP request node which will be the right node for you. Just choose post as a method there and send the data needed by adding it as body content. Happy to help if you’re getting stuck there somehow.
Thank you very much for the welcome and for your return to my question.
I found the HTTP request node on n8n, but I have no idea how to input data into it…
There are the authentication steps and the data integration itself. This is all very confusing to me. Honestly, I’m lost!
For example, regarding authentication, the CRM documentation says:
“To consume any Sigavi API, it is necessary to use an authentication API. For authentication, our API will request the parameters below:
username: Enter the system to obtain the username and password
password: Enter the system to obtain the username and password
grant_type: password
Field Layout: Click here
Endpoint: https://link.sigavi360.com.br/Sigavi/api/Acesso/Token
A token will be returned through the “access_token” parameter, valid for 24 hours.
The type of token used is bearer, so in the request of all other methods, pass a parameter called Authorization in the header and the content must be “bearer + “ “ + access_token””
In the HTTP request node there is the authentication option Generic Credential Type and, in sequence, Generic Auth Type. In none of the available options did I find enough fields to put the parameters above… I’ve stopped there!
To continue the rest and make the equivalence of fields, I will certainly have the same problem.
Any tips for me?
Once again, thank you for your patience and attention.
Hi @Edney. Do you have a link to the repective documentation? In n8n we offer a number of ways to authenticate in the HTTP node, but based on your message above, I don’t know what the right one for your need is.
Based on your message above, it sounds like the following:
Create a HTTP request with post to https://link.sigavi360.com.br/Sigavi/api/Acesso/Token to receive the authentication token. In her use the Generic Credential Type in the Authentication dropdown, together with Basic Auth in Generic Auth type. In there you can then enter your username + password
Now use the authentication token in a next http request node to request the real endpoint (e.g. https://link.sigavi360.com.br/Sigavi/api/Leads/NovaLead ). In here choose Header Auth in the Generic Auth Type dropdown. In there enter authentication as name and bearer <token> as value.
Here’s an example in which you of course have to add the right parameters (as I can’t test your CRM without credentials). You might need to play around with it a little.
I followed your instructions for the first authentication node and this error message popped up:
ERROR: Bad request - please check your parameters
Details
HTTP Code: 400
Cause
Data below may contain sensitive information. Proceed with caution when sharing.
{
“status”:“rejected”,
“reason”:{
“message”:“400 - “{"error":"unsupported_grant_type"}””,
“name”:“Error”,
“stack”:“Error: 400 - “{"error":"unsupported_grant_type"}” 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:525:35) at IncomingMessage.emit (node:domain:489:12) at endReadableNT (node:internal/streams/readable:1358:12) at processTicksAndRejections (node:internal/process/task_queues:83:21)”
}
}
Stack
NodeApiError: Bad request - please check your parameters
at Object.execute (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/HttpRequest/V3/HttpRequestV3.node.js:1167:27)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at Workflow.runNode (/usr/local/lib/node_modules/n8n/node_modules/n8n-workflow/dist/Workflow.js:658:28)
at /usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/WorkflowExecute.js:585:53
I followed your instructions, and after a few tries and tests, I was able to authenticate! However, I used the Form Urlencoded in the Body Content Type to introduce the access parameters, in addition to including the Send Headers parameters in the same node, as you can see in the print below (thanks a lot for your great help!):
Now, I just need to know how to capture the data from Mautic (first node), do the equivalence and send them to the CRM (third node).
When I run the third node to send the data to the CRM, I can’t access the data from the first one (Mautic), only the second one (authentication).
Is there any way for the second node (authentication) to capture data from the first (Mautic) and forward it directly to the CRM, without the need for a third node? Or is there a way to capture the parameters between nodes of different connections?
You can reference any node when trying to use data. In your case, just toggle the input to Expression and enter {{ $node["Mautic Trigger"].json["propertyYouWantToAccess"] }} in there. You can also easily browse through the data you can use by opening the expression modal (as seen in screenshots below)