Getting error 400 'Invalid JSON Web Token' from a rest query

I can’t tell if I am getting this error from Retool or if Retool is simply passing the error from the Carbone API. Dev tools says I am getting the 400 error from a retool.com URL:

Here is the URL:

https://las.retool.com/api/pages/uuids/e201ec60-7891-11eb-850c-c388bce7e886/query?queryName=restRenderInvoice

This is the response I getting back (body redacted for brevity)

{
	"statusCode": 400,
	"error": "Bad Request",
	"message": "{\"success\":false,\"error\":\"Error: Invalid JSON Web Token: Not enough or too many segments\"}",
	"data": {
		"success": false,
		"error": "Error: Invalid JSON Web Token: Not enough or too many segments"
	},
	"metadata": {
		"request": {
			"url": "https://render.carbone.io/render/9e7d7b1fa3873ec4c66a3c78c20d0e9311692787cbf1894decfedc2e6c45a259",
			"method": "POST",
			"body": "{}",
			"headers": {
				"User-Agent": "Retool/2.0 (+https://docs.tryretool.com/docs/apis)",
				"Authorization": "---sanitized---",
				"carbone-version": "2",
				"Content-type": "application/json",
				"Content-Type": "application/json",
				"X-Retool-Forwarded-For": "4.35.210.206"
			}
		},
		"headers": {
			"access-control-allow-origin": ["*"],
			"access-control-expose-headers": ["X-Request-URL,Content-Disposition"],
			"content-type": ["application/json"],
			"date": ["Thu, 25 Mar 2021 00:57:32 GMT"],
			"connection": ["keep-alive"],
			"content-length": ["90"]
		},
		"status": 500,
		"statusText": "Internal Server Error"
	}
}

I am bumping this. If no one knows what might be causing this, anyone have any advice on how I go about debugging this? First off how to determine if this error is originating with Retool or Cabone? I’m kinda stuck. Thanks.

Hey Bradley,That error doesn’t look like it is coming from Retool, but one way to confirm would be trying to run the same query from another tool like Postman to see if you get the same error. Also if you could post a screenshot of your resource setup page (with any confidential bits redacted) I am happy to take a look to see if there is anything that seems off.

@mark,

Ok, got it working in Nightingale with the help of David at Carbone. But, to get it working I needed to put the authorization in the Auth section, not the Headers section for some reason. Next I tried to put the Auth data in the resource’s Headers rather than the query and it worked.

An additional note for others, do not put “body: {…}” in the body section :upside_down_face:, it get’s duplicated.

Nice! I’m glad you were able to get it working! If anything comes up in the future, don’t hesitate to reach out again, either here in the community, or via the chat bubble icon inside Retool!