Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't show simple results API usage examples for parameterized queries #3815

Open
gggooo opened this issue May 20, 2019 · 7 comments
Open

Don't show simple results API usage examples for parameterized queries #3815

gggooo opened this issue May 20, 2019 · 7 comments

Comments

@gggooo
Copy link

gggooo commented May 20, 2019

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.

@gggooo gggooo changed the title Results in JSON format:{{url}} got wrong queries api key not work May 20, 2019
@arikfr
Copy link
Member

arikfr commented May 20, 2019

Does your query use parameters?

@gggooo
Copy link
Author

gggooo commented May 21, 2019

@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.

@rauchy
Copy link
Contributor

rauchy commented May 21, 2019

@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.

@gggooo
Copy link
Author

gggooo commented May 22, 2019

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

@gggooo gggooo closed this as completed May 22, 2019
@arikfr arikfr changed the title queries api key not work Don't show simple results API usage examples for parameterized queries May 22, 2019
@arikfr arikfr reopened this May 22, 2019
@arikfr
Copy link
Member

arikfr commented May 22, 2019

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

Thank you for bringing this to our attention.

@kishandonepudi
Copy link

@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

@rauchy
Copy link
Contributor

rauchy commented Jul 30, 2019

@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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants