Selfhosted API not working ;(

Hey! We have 0.41 selfhosted and we are having a very hard time getting the API to work with our integrations (such as windmill). Authorization over the API is working fine (not able to access the api call documentation and trying it out without provision of proper API key), however, every tested API Call returns 500 internal server error. Not connected to basic functionality (show companies) or customized (show custom objects)
28 Replies
thomast
thomast3w ago
hey, can you share the query you made and the error?
armochillo
armochilloOP3w ago
according to API Documentation /developers/rest-api/core depth : Not Set12 select an option (defaults to: 1) ending_before : string filter : example: createdAt[gte]:"2023-01-01" Pick an examplesimplesimpleNestedcomplex select an option limit : defaults to: 60 order_by : example: createdAt Pick an examplesimplecomplex select an option starting_after : string Result: 500 Internal Server Error No supported response body returned
thomast
thomast3w ago
I don't get it. You said you are self hosting. So you must have your own twenty app running on your own url?
armochillo
armochilloOP3w ago
Twenty.com
Open Source CRM
armochillo
armochilloOP3w ago
yes, still using the api doc you are hosting to validate the API calls while switching to other environment and putting in the address of our own self hosted environment
thomast
thomast3w ago
so you also have an account in cloud to call?
armochillo
armochilloOP3w ago
no, I created in our twnetycrm system an API Key, provided the custom path in the URL that I just posted, put in API key, got success ful authentication . or are you telling me that its not possible to use this kind of API documentation with live testing with self hosted? If that is the case, how can we test against our own API? I am asking this because we try to connect windmill (selfhosted) with twentyCRM (selfhosted) but we want to ensure that API is working correctly on twentyCRM side and I was under the impression that testing API can be done easily with this swagger like doc
thomast
thomast3w ago
got it. If you set up your url, add your api key and see all expected endpoints it means your setup is good. But then do you see errors in backend logs ?
armochillo
armochilloOP3w ago
Yes correct! I could also see custom API calls for the custom objects. Will refer to system admin and produce logs, just a sec,. thanks! 100.82.116.198 - - [12/Feb/2025:16:49:10 +0000] "GET /rest/notes HTTP/1.1" 500 0 "https://twenty.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36 Edg/133.0.0.0" "-" Only found this in the http proxy container We are wondering wether this might be the issue? and if yes, what should be the values for those variables? 🤔 "Yes, there is an issue with the docker-compose on main, please add both REDIS_HOST and REDIS_URL for now I think that's it, the REST API is making an http call to the Graphql API for now (we are changing it, likely this month) so you might have faced networking issue docker compose ports: 3010:3000 <---- it seems the system uses the internal running port as part of the token generation I changed to run on 3010 via the env var and the internal port mapping and voila" @thomast not sure if we configured something wrong on our side
thomast
thomast3w ago
so your request goes as expected to the proxy. Can you share the logs of your server? 500 should come from there. Maybe it's Redis, maybe something else but you should see something in twenty-server logs
armochillo
armochilloOP3w ago
thanks, let us check 100.82.116.198 - - [14/Feb/2025:09:08:21 +0000] "GET /rest/apiKeys HTTP/1.1" 500 0 "https://twenty.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:134.0) Gecko/20100101 Firefox/134.0" "-" 100.82.116.198 - - [14/Feb/2025:09:08:27 +0000] "GET /rest/auditLogs HTTP/1.1" 500 0 "https://twenty.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:134.0) Gecko/20100101 Firefox/134.0" "-" 100.82.116.198 - - [14/Feb/2025:09:08:31 +0000] "GET /rest/attachments HTTP/1.1" 500 0 "https://twenty.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:134.0) Gecko/20100101 Firefox/134.0" "-" 100.82.116.198 - - [14/Feb/2025:09:08:42 +0000] "GET /rest/attachments/tst HTTP/1.1" 500 0 "https://twenty.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:134.0) Gecko/20100101 Firefox/134.0" "-" It is not possible for us to find other logs in regards of those API call attempts
charles
charles3w ago
Hi @armochillo, could you check your server logs? (docker logs {containerId} if you are using docker If the requests is hitting your container you'll see it there you can also try to make the query with curl (I believe it's possible to copy as curl from the REST api docs, not 100% sure) and see if you are having the same result while hitting direclty your server, or your container
armochillo
armochilloOP3w ago
Hey, thanks for the suggestion, will refer to devops and come back to you 🙂 thanks!
charles
charles3w ago
You are welcome, let us know
armochillo
armochilloOP3w ago
We were able to create some logs after firing the curl requests that were copy pasted from the api documentation
David
David3w ago
@armochillo @charles Not trying to hijack this topic, but if that can help anyone, I am having the same issue. Running 0.41 as well. I am using n8n with the community-node. I run n8n in a docker, same for twenty, both are on the same docker network. I get a successful connection using the credential: http://twenty-server-1:3000. However, for any api call, I always have a error 500. When I use a temp container and curl using this command: sudo docker run --rm --network container:n8n curlimages/curl:latest curl -I --request GET \ --url 'http://twenty-server-1:3000/rest/companies/490a5309-8239-4b1f-be34-72e51cfa85ab?depth=1' \ --header 'Accept: application/json' \ --header 'Authorization: Bearer "API KEY"' I get this error: HTTP/1.1 500 Internal Server Error X-Powered-By: Express Access-Control-Allow-Origin: * Access-Control-Allow-Methods: GET,HEAD,PUT,PATCH,POST,DELETE Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept Content-Type: application/json; charset=utf-8 Date: Mon, 17 Feb 2025 16:29:39 GMT Connection: keep-alive Keep-Alive: timeout=5 Content-Length: 0 Same when I try from the developer section on twenty.com, I put in my external domain name with my api key, and I am able to see the api call documentation, but I get the same error 500 return on any api calls. No logs show either way in the server logs. Is there any feature flags that need to be activated or variable that need to be set in the environment?
armochillo
armochilloOP3w ago
No worries, welcome to the party 😄 the more, the merrier
Prastoin
Prastoin3w ago
That means you use raw catalog or your catalog doesn't have a translation for the message and fallback was used. ICU features such as interpolation and plurals will not work properly for that message. Please compile your catalog first. Uncompiled message detected! Message: 0exG4Q That means you use raw catalog or your catalog doesn't have a translation for the message and fallback was used. ICU features such as interpolation and plurals will not work properly for that message. Please compile your catalog first. Uncompiled message detected! Message: DXPGs/ That means you use raw catalog or your catalog doesn't have a translation for the message and fallback was used. ICU features such as interpolation and plurals will not work properly for that message. Please compile your catalog first.
Unless I'm mistaken theses logs are lingui translations errors, they should not be blocking but are making noise in twenty-server logs right now Not sure but running below commands should fix these logs and makes some spaces in traces
npx nx run twenty-server:lingui:extract
npx nx run twenty-server:lingui:compile
npx nx run twenty-server:lingui:extract
npx nx run twenty-server:lingui:compile
armochillo
armochilloOP2w ago
so esentially @David and myself are receiving 500 error for almost all API Calls (did you try to submit the get Api Scheme Call? This worked for me, 200 returned) and it is not possible to retrieve anything in the logs, feels like we are stuck 😦
charles
charles2w ago
Hi @armochillo, would you be availalble for a call later this week?
armochillo
armochilloOP2w ago
sure, would like to send you a calendar book link via pm
armochillo
armochilloOP2d ago
We installed the 0.43.1 tag on twentyCRM selfhosted and now the docker logs of server-1 show this. When I try to call e.g. "Find Company duplicates" I get: Exception Captured { user: undefined, workspace: undefined } [ TypeError: Cannot read properties of undefined (reading 'data') at RestApiService.call (/app/packages/twenty-server/dist/src/engine/api/rest/rest-api.service.js:51:71) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async RestApiCoreService.findDuplicates (/app/packages/twenty-server/dist/src/engine/api/rest/core/rest-api-core.service.js:46:16) at async RestApiCoreController.handleApiFindDuplicates (/app/packages/twenty-server/dist/src/engine/api/rest/core/controllers/rest-api-core.controller.js:35:24)
No description
armochillo
armochilloOP2d ago
@charles I believe the execption catching is working as intendend! 👍 { "statusCode": 400, "error": "TypeError", "messages": [ "Cannot read properties of undefined (reading 'data')" ] } Getting 400 now instead of 500, interestingly
charles
charles2d ago
@armochillo that's strange Log into your container to the rest-api.service.js (see path in your error message), edit the file to add a "console.log(url)" then try again on the rest API (no need to restart your container)
armochillo
armochilloOP2d ago
where to add exactly, anywhere, e.g. at top? 😄
charles
charles2d ago
right below url definition url = baseUrl...
armochillo
armochilloOP13h ago
thanks! We changed it, now we get this out of logfiles: Exception Captured { user: undefined, workspace: undefined } [ TypeError: Cannot read properties of undefined (reading 'data') at RestApiService.call (/app/packages/twenty-server/dist/src/engine/api/rest/rest-api.service.js:51:71) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async RestApiCoreService.get (/app/packages/twenty-server/dist/src/engine/api/rest/core/rest-api-core.service.js:26:16) at async RestApiCoreController.handleApiGet (/app/packages/twenty-server/dist/src/engine/api/rest/core/controllers/rest-api-core.controller.js:39:24) ] Exception Captured { user: undefined, workspace: undefined } [ TypeError: Cannot read properties of undefined (reading 'data') at RestApiService.call (/app/packages/twenty-server/dist/src/engine/api/rest/rest-api.service.js:51:71) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async RestApiCoreService.get (/app/packages/twenty-server/dist/src/engine/api/rest/core/rest-api-core.service.js:26:16) at async RestApiCoreController.handleApiGet (/app/packages/twenty-server/dist/src/engine/api/rest/core/controllers/rest-api-core.controller.js:39:24) ] You want me to trigger a certain API Function for further testing? @charles
armochillo
armochilloOP13h ago
this is how we changed the file
No description

Did you find this page helpful?