hi ,dear redash team:

I want to use these api directly as a way for me to check the data;

api method
…/api/query_results POST
…/api/jobs/{query_hash} GET
…/api/query_results/{query_result_id} GET

But if don’t log in first, will get this message:

Couldn't find resource. Please login and try again

I would like to ask, how can I skip the login restrictions, so that other systems can directly use these three api, and the three api of his own web page are still restricted by the login status

I have an idea;

Create three new apis, continue to call those three methods, and then do the login verification skipping for the new API

Now the question is how do I skip login validation?

You don’t need to login to use the API. Just include an Authorization header with your API requests. Documentation here.

1 Like

wow! thank you !thank you !thank you !thank you !(It’s so important that it should be repeated for three times.)

I found the configuration for the API key in edit profile.
also seen examples of the redash-toolbelt project.
Thank you for your help!!!

You can do lots of cool things with the API :wink:

Here’s an example refreshing a dashboard:

1 Like

Ok ok, got it.!!! thank you for your help!

Hi @jesse
I added headers
Authorization=Key {{user api_key}}
Accept=/
Content-Type=application/json
to request POST {{redash_url}}/api/query_results
but it not work, it still show error 404 ```
Couldn’t find resource. Please login and try again

How can i pass this error

api/query_results is not a valid endpoint. You’re seeing a 404 error which means the resource is not found.

What are you trying to do?

I’m just trying create new query. I use endpoint /api/queries to do this but still get same error

Without further information it’s hard to know the issue. If you can share the curl for your request that will be easier to debug :smiley:

Here is curl
curl --location --request POST ‘{{redash_url}}/api/queries’
–header ‘Key: {{api_key}}’
–header ‘Content-Type: application/json’ \

–data-raw '{

"data_source_id": 172,

"parameters": {},

"query": "select * from seller",

"max_age": 0

}’

Response:
{

"message": "Couldn't find resource. Please login and try again."

}

There are a lot of problems with your curl. Here’s an example of one that will work:

curl --request POST \
  --url $REDASHOST/api/queries \
  --header 'Authorization: Key bz7VWCYfUagx7dsfBdFPhYlhBzdznDD1i2TLiDUg' \
  --data '{
	"data_source_id": 1,
	"name": "Example Query",
	"query": "select * from seller"
}'

A few issues with yours:

  • max_age is not accepted when creating or modifying queries. That only matters when executing a query.
  • Your query has no name declaration. This will fail.
  • You did not include an Authorization header. This is why you receive a 404. Probably would be better to receive a 400, honestly, but that would actually reveal too much information (i.e. this resource exists but you can’t access it). The API simply returns a 404 if you aren’t authorised properly.
  • You’re using a GET request when a POST is required to create a new query.