Hi all,
I’m able to get refresh query results by following this example on Github .
I’m, however, experiencing some difficulties in getting fresh results with an added parameter . The results of the POST request with one parameter always lead to this error:
{
"job": {
"status": 4,
"error": "Missing parameter value for: action"
}
}
Since the problem occurs only, when I try to refresh results with one parameter, my suspicion is that I’m passing the parameter to the POST request in the wrong format. In Postman , I’m adding the parameter to the body of the request in the following format:
{"p_action": "%example.org%"}
Any help or hints to get me on the right track would be really appreciated. If I can provide more details, I’d be happy to do so.
Thank you in advance!
okay, i’ve fixed the problem.
i could get fresh results by passing the parameter in the url of the POST request rather than in the body (as i usually do).
a bit counterintuitive for me, as I’m used to passing parameters in the body of the request, this seems to do the trick:
https://query.redash_url.com/api/queries/query_id/refresh?p_action=%example.org
Hi, you could share the code to refresh the querys.
and this parameter query_id you get from some system table this query_id is the number of the query to search
1 Like
gbaldelli:
i could get fresh results by passing the parameter in the url of the POST request rather than in the body (as i usually do).
a bit counterintuitive for me, as I’m used to passing parameters in the body of the request, this seems to do the trick:
https://query.redash_url.com/api/queries/query_id/refresh?p_action=%example.org
Hi, I have tried to use your tip, but it does not work: I have “Please use a user API key” error.
My query is something like
select * from cioppi.cioppiplus_fatture where annoemissione = {{annoemissione}}
What’s my error?
Thank you
jesse
October 21, 2019, 12:44pm
6
When you send POST requests like this, you should include a header with your user API key. The header will look like this:
Authorization: Key <your API key>
You can get your user API key from the profile screen under settings.
Then remove the api_key
query string variable since it doesn’t matter here.
1 Like
jesse:
When you send POST requests like this, you should include a header with your user API key. The header will look like this:
Authorization: Key <your API key>
Thank you, but I’m not able to have results.
If I run
curl --request POST \
--url 'http://172.xxx.xxx.221:8080/api/queries/34/refresh?p_annoemissione=2019' \
--header 'Authorization: Key : xxxxxxxxxxx \
--header 'cache-control: no-cache'
I have
{
"message": "Couldn't find resource. Please login and try again."
}
What’s wrong in my request?
The resource is there because If I run
curl "http://172.xxx.xxx.221:8080/api/queries/34/results.csv?api_key=xxxxxxxxxxx "
the server reply
{"message": "No cached result found for this query. You have requested this URI [/api/queries/34/results.csv] but did you mean /api/query_results or /api/queries/<query_id>/refresh or /api/query_results/<query_result_id> ?"}
Thank you
@jesse there was an error in my command. I have edited it.
Now if I run
curl --request POST \
--url 'http://172.xxx.xxx.221:8080/api/queries/34/refresh?p_annoemissione=2017' \
--header 'Authorization: Key xxxxxxxxxxx '
I have
{
"job": {
"status": 2,
"error": "",
"id": "b9b58e2f-ca57-40d3-a9e3-72d42e92ba2f",
"query_result_id": null,
"updated_at": 0
}
}
I do not know the meaning of status code 2
. Now how can I download the refreshed query output?
Thank you
jesse
October 22, 2019, 12:15pm
9
For others reading this in the future. The error was @aborruso included a colon :
in the Authorization
header.
Have a look at this gist .
// 1 == PENDING (waiting to be executed)
// 2 == STARTED (executing)
// 3 == SUCCESS
// 4 == FAILURE
// 5 == CANCELLED
You will need to poll this endpoint until the query execution completes, indicated by status code 3. A code 3 will include a query_result_id
. The results will then be available from:
/api/queries/<your query id>/results/<query_result_id>.json
2 Likes
@jesse you are really very kind!!
Tomorrow I will try. I think I will write at the end a dedicated “README”.
Thank you
1 Like
Hi @jesse ,
it the status after 24 hours (it’s not a complex query) is still 2
, what can I do? Why the status remains fixed to 2
?
Thank you
Hi @jesse ,
sorry if I insist, but I’m stuck on this point.
If the status after 24 hours (it’s not a complex query) is still 2
, what can I do? Why the status remains fixed to 2
?
Thank you
jesse
October 26, 2019, 9:20pm
13
Can you give more detail about exactly which endpoints you are hitting and the responses you receive?
Yes, thank you @jesse
These the details.
The query
select * from example.example_inv where annoemissione = {{annoemissione}}
The command I run
curl --request POST \
--url 'http://mysite:8080/api/queries/34/refresh?p_annoemissione=2018' \
--header 'Authorization: Key XXXxxx'
The reply I have
{
"job": {
"status": 2,
"error": "",
"id": "5a703e10-c7ca-4b41-bf64-827937083f74",
"query_result_id": null,
"updated_at": 0
}
}
jesse
November 16, 2019, 8:48pm
16
What happens if you check api/jobs/5a703e10-c7ca-4b41-bf64-827937083f74
?
I have
{
"job": {
"status": 3,
"error": "",
"id": "1a2f6e38-9873-455d-a3cb-ff89d06ec0e8",
"query_result_id": 1221,
"updated_at": 0
}
}
Then the way to do it is (for me) this.
I start from
curl --request POST \
--url 'http://myURL.com/api/queries/34/refresh?p_field=2019' \
--header 'Authorization: Key xxxXXXxxx'
and I have
{
"job": {
"status": 2,
"error": "",
"id": "477860cf-28fc-4cb4-84d6-9cf5aa299e2c",
"query_result_id": null,
"updated_at": 0
}
}
Then I get the id
and run
curl --request GET \
--url 'http://myURL.com/api/jobs/477860cf-28fc-4cb4-84d6-9cf5aa299e2c' \
--header 'Authorization: Key xxxXXXxxx'
and I have.
{
"job": {
"status": 3,
"error": "",
"id": "477860cf-28fc-4cb4-84d6-9cf5aa299e2c",
"query_result_id": 1223,
"updated_at": 0
}
}
then I get query_result_id
and at the end I have the query result running
curl --request GET \
--url 'http://myURL.com/api/queries/34/results/1222.json' \
--header 'Authorization: Key xxxXXXxxx'
Am I right?
Thank you
1 Like
jesse
November 19, 2019, 2:53am
18
Yes that looks right. I’ll see about adding an example of this to our documentation. I know we hope to improve this interface going forward.