Internal server error - Cannot read properties of undefined (reading 'length')

I'm attempting to make a POST request, but I keep encountering this error: 'Internal server error - Cannot read properties of undefined (reading 'length').' The request has a raw body with a couple of simple data points, nothing unusual. I've tried the same request in Postman, and it works fine there.

Please help :worried:

Hi @Tabella,

It looks like the query is fine. I tested a similar query and it works. It maybe something to do with your response. Would you mind sharing a sample response from the end point?

Hi! Sure, thank you.


I have double-checked the URL, the parameters, everything. However, I still receive that response from Retool, but the same request works fine in Postman.

Hmm those looks fine. If you click on the "API Request" tab on Retool UI (it's next to "Response"), what do you see? It'll also help to share a screenshot of that.

{
"request": {
"url": "https://tabella-connection.herokuapp.com/api/v1/communities/relation",
"method": "POST",
"body": "{"id":"SaintPeter-Mertzon","parentId":"Diocese-4","childTypeName":"Parish"}",
"headers": {
"User-Agent": "Retool/2.0 (+https://docs.tryretool.com/docs/apis)",
"Authorization": "---sanitized---",
"ot-baggage-requestId": "undefined",
"x-datadog-trace-id": "8700139179157712507",
"x-datadog-parent-id": "8903674363730136149",
"x-datadog-sampling-priority": "-1",
"traceparent": "00-000000000000000078bd1a7cf6276e7b-7b9034a8fde30c55-00",
"tracestate": "dd=s:-1",
"X-Retool-Forwarded-For": "190.165.110.157"
}
},
"response": {
"data": {
"status": "error",
"message": "Internal server error - Cannot read properties of undefined (reading 'length')"
},
"headers": {
"server": [
"Cowboy"
],
"report-to": [
"{"group":"heroku-nel","max_age":3600,"endpoints":[{"url":"https://nel.heroku.com/reports?ts=1712760465&sid=1b10b0ff-8a76-4548-befa-353fc6c6c045&s=iItBliHYA7bKtOGflDzr5mBsqp33HGaQ7Uf%2FJ4eyk0s%3D\"}]}"
],
"reporting-endpoints": [
"heroku-nel=https://nel.heroku.com/reports?ts=1712760465&sid=1b10b0ff-8a76-4548-befa-353fc6c6c045&s=iItBliHYA7bKtOGflDzr5mBsqp33HGaQ7Uf%2FJ4eyk0s%3D"
],
"nel": [
"{"report_to":"heroku-nel","max_age":3600,"success_fraction":0.005,"failure_fraction":0.05,"response_headers":["Via"]}"
],
"connection": [
"keep-alive"
],
"x-powered-by": [
"Express"
],
"access-control-allow-origin": [
"*"
],
"content-type": [
"application/json; charset=utf-8"
],
"content-length": [
"109"
],
"etag": [
"W/"6d-icu2kgFMdCSZdKRrdmWTkDVX9DM""
],
"date": [
"Wed, 10 Apr 2024 14:47:45 GMT"
],
"via": [
"1.1 vegur"
]
},
"status": 500,
"statusText": "Internal Server Error"
}
}

@Tabella It looks like the error comes from your server (status: 500 in the metadata). The body looks as expected. The request we send looks normal as well. I suspect it can be some default headers we have is missing or not as expected. Like I don't see "application/json" type in the body.

  • Can you change the body format from "RAW" to "JSON"?
  • Can you check your server on heroku to see if there is any crash log related to the error Cannot read properties of undefined (reading 'length')"?

Changing from RAW to JSON worked!!! Thank you soooooo much!!!!