Redash: Don't show simple results API usage examples for parameterized queries

Created on 20 May 2019  Â·  7Comments  Â·  Source: getredash/redash

When you open the API Key dialog for a query, we show results API usage examples:

image

These examples will not work in the case of a parameterized query. We should at least replace the examples with a message explaining this or preferably show something along the lines of @rauchy's comment.

Frontend UX help wanted

All 7 comments

Does your query use parameters?

@arikfr

Does your query use parameters?

Thankyou for your reply! Now I know why this problem happened.

and How to use the query API with parameters, is there anything like api document?

Sorry for the inconvenience.

@gggooo if you want to execute a query with parameters using the API, you should POST to /queries/{id}/results and your POST body should include a parameters key, for example:

{
  "parameters": {
    "param1": 123,
    "param2": 456
  }
}

If you're trying to embed a visualization with parameters, make sure none of your parameters are textual params and that your code is up-to-date, as this feature was released not long ago.

@rauchy Thankyou for your reply! I will try to use it, thanks!

@gggooo I reopened your issue and updated the description to reflect a possible solution.

Thank you for bringing this to our attention.

@gggooo if you want to execute a query with parameters using the API, you should POST to /queries/{id}/results and your POST body should include a parameters key, for example:

{
  "parameters": {
    "param1": 123,
    "param2": 456
  }
}

If you're trying to embed a visualization with parameters, make sure none of your parameters are textual params and that your code is up-to-date, as this feature was released not long ago.

@rauchy can you please share me your postman collection or else a guide in notes pls

@gggooo I don't use Postman that much, but here's the simplest curl command you can run which demonstrates this:

curl http://<host>/api/queries/<query_id>/results?api_key=<query_api_key> --data-binary '{"parameters":{"<param_name>":<param_value>}}'

Does this help?

Was this page helpful?
0 / 5 - 0 ratings