Problem: Couldnāt connect n8n with SuiteCRM - getting 404, 500, āunsupported_grant_typeā errors
AFTER 3 DAYS OF STRUGGLE - HEREāS THE COMPLETE SOLUTION:
PROBLEMS ENCOUNTERED AND SOLUTIONS:
1. ERROR 500: Missing OAuth2 Keys
bash
THIS STEP IS CRITICAL! docker exec -it suitecrm bash cd /bitnami/suitecrm/public/legacy/Api/V8/OAuth2/ openssl genrsa -out private.key 2048 openssl rsa -in private.key -pubout -out public.key chmod 600 private.key public.key chown daemon:daemon private.key public.key exit docker-compose restart suitecrm
2. ERROR 404: Wrong Endpoint
DONāT use: /api/oauth/token or /rest/v1/oauth/token
USE: /legacy/Api/access_token
3. ERROR 400: Wrong Configuration
Content-Type MUST be: application/vnd.api+json (NOT application/json )
EXACT n8n CONFIGURATION:
Step 1: Create OAuth2 Client in SuiteCRM
- Go to Admin ā OAuth2 Clients
- Create āPassword Grantā client
- Note: Client ID and Client Secret
Step 2: n8n HTTP Request Node - Get Token
text
URL: http://suitecrm:8080/legacy/Api/access_token Method: POST Headers: - Content-Type: application/vnd.api+json - Accept: application/vnd.api+json Body (JSON): { āgrant_typeā: āpasswordā, āclient_idā: āYOUR_CLIENT_IDā, āclient_secretā: āYOUR_CLIENT_SECRETā, āusernameā: āadminā, āpasswordā: āAdmin123ā }
Step 3: Use the Token
text
URL: http://suitecrm:8080/Api/V8/Modules Method: GET Headers: - Content-Type: application/vnd.api+json - Accept: application/vnd.api+json - Authorization: Bearer {{ $json.access_token }}
KEY DISCOVERIES:
- SuiteCRM OAuth2 is VERY particular about formats
- Content-Type MUST be
application/vnd.api+json(not regular JSON) - Endpoint is
/legacy/Api/access_tokenin many installations - OAuth2 keys MUST be generated manually - they donāt auto-create
WORKING ENDPOINTS TO TEST:
/Api/V8/Modules- List available modules/Api/V8/Accounts- Get accounts/Api/V8/Contacts- Get contacts/Api/V8/Leads- Get leads
TIME INVESTMENT: 3 days ā Now works in 5 minutes!
DONāT GIVE UP! The integration is possible, just very poorly documented. Once configured, it works perfectly.
Hope this saves someone else the headache!
ā:blush:
suitecrm #n8n #API #OAuth2 #Integration #Automation