Google-bigquery how to get datasetlist with https get?
I am trying to get a list of datasets from bigquery webserver with https get
following the documentation: https://developers.google.com/bigquery/docs/reference/v2/datasets/list
I am using slightly modified code:
http://code.google.com/p/qt-google-bigquery/source/browse/manager_bigquery.cpp
getDatasetsList(QString strProjectID)
{
QString url = QString("https://www.googleapis.com/bigquery/v2/projects/%1/datasets?key=%2").arg(str_ProjectID).arg(this->api_key);
//Also tried without ?key= part
QNetworkRequest request;
request.setUrl( QUrl(url) ); //this also urlencodes
request.setRawHeader("Content-Type", "application/json");
request.setRawHeader("Authorization", (QString("Bearer %1").arg(m_Access_Token)).toLatin1());
//here i post the request as a http get asynchronously
}
i will return this error message:
Reply = "{
"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "Required parameter is missing"
}
],
"code": 400,
"message": "Required parameter is missing"
}
}
Note:
I was able to run the query and get the results, so my access token seems to be valid, what am I doing wrong here?
solved
And, in fact, the problem was in my encoding, not in the request, I posted it as an http message, not getting it.
source to share
See the answer in the comment on the original poster above - but basically make sure you use GET instead of the POST method to call the API for a list of datasets. Other BigQuery API methods use POST, PUT, or PATCH.
https://developers.google.com/bigquery/docs/reference/v2/datasets/list
source to share