N8n call to local ERPNext instance not working

Im trying to create a API call from my local n8n instance to my local erpnext instance. Both are the current version as of last week.
A connection to a erpnext instance on erpnext.com is able to connect with eas.
The local call to erpnext hower fails.
Can someone verify the function with a local erpnext installation?

The erpnext connector throws the following error at me:

Forbidden - perhaps check your credentials?

403 - {“exception”:“frappe.exceptions.PermissionError”,“exc_type”:“PermissionError”,“exc”:“["Traceback (most recent call last):\n File \"apps/frappe/frappe/app.py\", line 110, in application\n response = frappe.api.handle(request)\n File \"apps/frappe/frappe/api/init.py\", line 49, in handle\n data = endpoint(**arguments)\n File \"apps/frappe/frappe/api/v1.py\", line 76, in read_doc\n raise frappe.PermissionError\nfrappe.exceptions.PermissionError\n"]”,“_server_messages”:“["{\"message\": \"User Guest does not have doctype access via role permission for document Currency
User Guest does not have access to this document\", \"title\": \"Message\"}"]”}

Additional informatin:
Userrights are set identicaly on local and cloud version. Both are new instances and the api key and secret has been checkt multiple times.

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

Thank you for the additional questions:
version 1.37.3
Database: Docker installation i guess (default: SQLite)
OS Ubuntu Container
EXECUTIONS_PROCESS default as it is in Docker i guess
Virtualisation: Proxmox

Well, the error is pretty straightforward. You should check the permissions for the api token and for that document

Well, that is exactly my problem.
The token should in my opinion authenticate as the service user, in my case [email protected], but it does not do that.
The same configuration with that api connecting to company.erpnext.com works without any issues. For me it looks like a issue with the connection to a local erpnext instance.
I have seen many other comments where people are having issues while communicating with a local erpnext installation.
I wonder if someone has it running locally?
I an other forum i have seen that the path set in n8n was pointing to the wrong path a while back and as a result of that the authentication was not successful. I wonder if that problem has reappeared.
Regardless of the access given to the API user as for my understanding the api call should always be working.
for now I’m always getting the folowing error
“Couldn’t connect with these settings
FORBIDDEN”
If I use the same user to connect to the api through the browser it works without any problems. This Tells me that the access rights are correct or am I wrong?

Have you tried to use the HTTP Request node to check if the credentials works as expected?
You can open the dev console (f12) and see the exact query to the API.

@Jon can you take a look into the node, maybe there is some issues with the configuration

The node itself looks to be ok, What I don’t get is why ERPNext is returning that error message which seems oddly specific.

according erpnext the “guest” account will be used if no user has been given for the authentication. Which in my opinion does not seem to be the case. I have checkt the request with the console in IE (results below) and with postman as well.
postman gives me basicaly the same “guest” error message as n8n.
For me it seems to be a Erpnext api issue.

[Node: “HTTP Request3”]

  1. {headers: {…}, method: ‘GET’, uri: ‘https://192.168.0.147/api/resource/Currency/usd’, gzip: true, rejectUnauthorized: false, …}

  2. auth: {user: ‘53ab0ce2eaf92ad’, pass: ‘** hidden **’}

  3. encoding: null

  4. followAllRedirects: true

  5. followRedirect: true

  6. gzip: true

  7. headers: {accept: ‘application/json,text/html,application/xhtml+xml,a…cation/xml,text/;q=0.9, image/;q=0.8, /;q=0.7’}

  8. json: false

  9. method: “GET”

  10. rejectUnauthorized: false

  11. resolveWithFullResponse: true

  12. timeout: 300000

  13. uri: “https://192.168.0.147/api/resource/Currency/usd

  14. useStream: true

  15. [[Prototype]]: Object

Reason why, im getting to the conclusion that it is a ERPnext api rights issue.

  1. Create user with no rights to the api and the resource i want to access.
  2. access the url https://192.168.0.147/api/resource/Currency/usd in browser as newly created user → result “not permitted” (so far so good)
  3. add permission to access api
  4. check in browser with url → iv been given the correct results.
  5. check api access with postman → Guest error
  6. check authentication with username and password → works without any problems

if someone could confirm that my conclusion is correct, that would be great.

Working curl for userbased login as also described in the documentation (Simple Authentication)

curl -X POST https://{your frappe instance}/api/method/login
-H ‘Content-Type: application/json’
-H ‘Accept: application/json’
-d ‘{“usr”:“Administrator”,“pwd”:“admin”}’

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.