Error in API bigquery.jobs.query() while using TABLE_DATE_RANGE - google-bigquery

In the recent two days I got an error in my process which worked successfully on a daily base in the recent year.
The bigquery.jobs.query() is not recognize the TABLE_DATE_RANGE (table wildcard function).
This is my Request (After I changed my ID):
POST https://www.googleapis.com/bigquery/v2/projects/foo/queries?key={YOUR_API_KEY}
Content-Type: application/json
Authorization: Bearer XXXXXX
X-JavaScript-User-Agent: Google APIs Explorer
{
"query": "SELECT COUNT( 1) AS CNT FROM TABLE_DATE_RANGE(DEV.FACT_,TIMESTAMP('20141018'),TIMESTAMP('20141019'))",
"dryRun": true,
"kind": "bigquery#queryRequest",
"defaultDataset": {
"datasetId": "DEV"
}
}
This is the response:
404 Not Found
- Hide headers -
cache-control: private, max-age=0
content-encoding: gzip
content-length: 146
content-type: application/json; charset=UTF-8
date: Sun, 19 Oct 2014 07:54:53 GMT
expires: Sun, 19 Oct 2014 07:54:53 GMT
server: GSE
{
"error": {
"errors": [
{
"domain": "global",
"reason": "notFound",
"message": "Not Found: Table foo:DEV.FACT_"
}
],
"code": 404,
"message": "Not Found: Table foo:DEV.FACT_"
}
}
When I Execute the query in the browser I get result.
When I remove the dryRun Attribute or set it to be False I get the result (200 OK)
Can Google explain what is the reason for this ?
Regards,
Liad

Thanks for the report.
It looks like TABLE_DATE_RANGE resolution is broken for dry run queries. I've filed a bug, we should have a fix soon. If you'd like to track the resolution, you can file a bug in the public issue tracker here: https://code.google.com/p/google-bigquery/.

Related

Permission denied while accessing Google Healthcare API from OAuth-2.0 playground

My request to google healthcare API is not working from OAuth 2.0 playground using refresh token option. I am getting "status": "PERMISSION_DENIED". The requested API has been enabled for many days. Here's the Request and Response details.
POST
/v1alpha2/projects/<project_id>/locations/<location>/datasets?
datasetId=<dataset_id> HTTP/1.1
Host: healthcare.googleapis.com
Content-length: 0
Content-type: application/json
Authorization: Bearer
HTTP/1.1 403 Forbidden
Content-length: 767
X-xss-protection: 0
X-content-type-options: nosniff
Transfer-encoding: chunked
Vary: Origin, X-Origin, Referer
Server: ESF
-content-encoding: gzip
Cache-control: private
Date: Fri, 12 Jul 2019 17:57:39 GMT
X-frame-options: SAMEORIGIN
Alt-svc: quic=":443"; ma=2592000; v="46,43,39"
Content-type: application/json; charset=UTF-8
{
"error": {
"status": "PERMISSION_DENIED",
"message": "Cloud Healthcare API has not been used in project <project_id> before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/healthcare.googleapis.com/overview?project=<project_ud> then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.",
"code": 403,
"details": [
{
"#type": "type.googleapis.com/google.rpc.Help",
"links": [
{
"url": "https://console.developers.google.com/apis/api/healthcare.googleapis.com/overview?project=<project_id>",
"description": "Google developers console API activation"
}
]
}
]
}
}
You are using the Alpha endpoint for the Healthcare API, which has been decomissioned by Google. You can see how to make the transition for the Beta API in here: https://cloud.google.com/healthcare/docs/how-tos/transition-guide.
Also note that in addition to the change in the Request URL
/v1beta1/projects/<project_id>/locations/<location>/datasets
the response now is a long-running operation:
https://cloud.google.com/healthcare/docs/reference/rest/v1beta1/projects.locations.datasets.operations

Google BigQuery Insert API returning 200 but not inserting data

Referencing https://cloud.google.com/bigquery/docs/reference/rest/v2/tabledata/insertAll
Google BigQuery API is returning 200 however the data is not being inserted in the table;
Request
POST https://www.googleapis.com/bigquery/v2/projects/***/datasets/***/tables/visits/insertAll?fields=insertErrors%2Ckind&key={YOUR_API_KEY}
{
"rows": [
{
"json": {
"hostId": "Value A",
"statusCode": "Value B"
}
},
{
"insertId": "inser-id-yo",
"json": {
"hostId": "Value A",
"statusCode": "Value B"
}
}
]
}
Response
Response: 200
cache-control: no-cache, no-store, max-age=0, must-revalidate
content-encoding: gzip
content-length: 69
content-type: application/json; charset=UTF-8
date: Fri, 16 Dec 2016 12:00:16 GMT
etag: "wWvNncJfeAdSHVaIWRpICxBS7AM/vyGp6PvFo4RvsFtPoIWeCReyIC8"
expires: Mon, 01 Jan 1990 00:00:00 GMT
pragma: no-cache
server: GSE
vary: Origin, X-Origin
{
"kind": "bigquery#tableDataInsertAllResponse"
}
My BigQuery table however is empty and no data is being inserted.
I know there a number of SDKs however I need to be able to do this via Curl as I am working in a language where Google have not developed and SDK.
Anyone else who had this problem, its because BigQuery can have up to a two hour delay.
It took me a while to find the answer.
Once i got rid of the line setInsertId(String.valueOf(System.currentTimeMillis()))
please see: Data streaming insertAll api usage not equal to actually inserted rows

StormPath Spring Boot Authentication Cookie generation

I just started using the stormpath-default-spring-boot-starter (1.2.0) library for new Rest API platform that we are building. I was expecting the access cookie to be generated by the following code on authenticating the user so that subsequent API calls can be authenticated by the cookie. Account is authenticated however the cookie is not getting generated.
AuthenticationRequest request = UsernamePasswordRequests.builder()
.setUsernameOrEmail(userId)
.setPassword(pwd)
.withResponseOptions(UsernamePasswordRequests.options().withAccount())
.build();
Account account = null;
try {
account = app.authenticateAccount(request).getAccount();
}
catch (ResourceException ex) {
throw(ex);
}
Following here is the property file entries,
stormpath.spring.security.enabled = false
security.basic.enabled = false
Help is much appreciated.
I think you may be mixing contexts here.
The code you provided looks like the type of manual code required when you are using the Java SDK directly and not using an integration, like the Stormpath Spring Boot integration.
When you are using the Stormpath Default Spring Boot Starter you get a bunch of endpoints automatically that you can use to authenticate and have cookies set.
For example, you have a /login endpoint.
If you fire up your example app, you should be able to go to:
curl localhost:8080/login
You will get back a login model that looks something like this:
{
"form": {
"fields": [
{
"name": "login",
"label": "Username or Email",
"placeholder": "Username or Email",
"required": true,
"type": "text"
},
{
"name": "password",
"label": "Password",
"placeholder": "Password",
"required": true,
"type": "password"
}
]
}
}
You can then authenticate with a POST:
curl -v -H "Content-Type: application/json" -X POST \
-d '{"login": "<email>", "password": "<password>"}' \
http://localhost:8080/login
You'll get a response like this:
> POST /login HTTP/1.1
> Host: localhost:8080
< HTTP/1.1 200
< Set-Cookie: access_token=eyJraWQiOiJSOTJTQkhKQzFVNERBSU1HUTNNSE9HVk1YIiwic3R0IjoiYWNjZXNzIiwiYWxnIjoiSFMyNTYifQ...;Max-Age=3600;path=/;HttpOnly
< Set-Cookie: refresh_token=eyJraWQiOiJSOTJTQkhKQzFVNERBSU1HUTNNSE9HVk1YIiwic3R0IjoicmVmcmVzaCIsImFsZyI6IkhTMjU2In0...;Max-Age=5184000;path=/;HttpOnly
< Content-Type: application/json
< Transfer-Encoding: chunked
< Date: Mon, 05 Dec 2016 05:30:25 GMT
<
* Connection #0 to host localhost left intact
{
"account": {
"href": "https://api.stormpath.com/v1/accounts/<account id>",
"createdAt": "2016-03-04T06:29:48.506Z",
"modifiedAt": "2016-08-17T18:01:07.812Z",
"username": "<username>",
"email": "<email>",
"givenName": "<givenName>",
"middleName": null,
"surname": "<surname>",
"status": "ENABLED",
"fullName": "<full name>",
"emailVerificationStatus": null,
"passwordModifiedAt": "2016-05-24T02:14:01.000Z"
}
}
The response contains both the access_token and the refresh_token cookies as well as a JSON response containing the account information.
If you want to use OAuth2, you have a /oauth/token endpoint that supports both the grant_type=password and the grant_type=client_credentials flow:
curl -v -X POST \
-d grant_type=password -d username=<email> -d password=<password> \
http://localhost:8080/oauth/token
You'll get a response like:
> POST /oauth/token HTTP/1.1
> Host: localhost:8080
< HTTP/1.1 200
< Set-Cookie: access_token=eyJraWQiOiJSOTJTQkhKQzFVNERBSU1HUTNNSE9HVk1YIiwic3R0IjoiYWNjZXNzIiwiYWxnIjoiSFMyNTYifQ...;Max-Age=3600;path=/;HttpOnly
< Set-Cookie: refresh_token=eyJraWQiOiJSOTJTQkhKQzFVNERBSU1HUTNNSE9HVk1YIiwic3R0IjoicmVmcmVzaCIsImFsZyI6IkhTMjU2In0...;Max-Age=5184000;path=/;HttpOnly
< Cache-Control: no-store, no-cache
< Pragma: no-cache
< Content-Type: application/json;charset=ISO-8859-1
< Content-Length: 933
< Date: Mon, 05 Dec 2016 05:38:53 GMT
<
* Connection #0 to host localhost left intact
{
"access_token": "eyJraWQiOiJSOTJTQkhKQzFVNERBSU1HUTNNSE9HVk1YIiwic3R0IjoiYWNjZXNzIiwiYWxnIjoiSFMyNTYifQ...",
"refresh_token": "eyJraWQiOiJSOTJTQkhKQzFVNERBSU1HUTNNSE9HVk1YIiwic3R0IjoicmVmcmVzaCIsImFsZyI6IkhTMjU2In0...",
"token_type": "Bearer",
"expires_in": 3600
}
I hope this helps!
Full disclosure: I am one of Stormpath's Java Developer Evangelists

PayPal Rest API. Why Agreement Id IS not Set

I'm using PayPal REST API to create agreement. I wonder why there is no id in the response when billing agreement is created. Only execute token is present in return_url.
When payment is created an id is returned.
Request
POST https://api.sandbox.paypal.com/v1/payments/billing-agreements HTTP/1.1
Content-Type: application/json
User-Agent: PayPalSDK/rest-sdk-dotnet 0.11.0 (core=1.6.0;lang=DOTNET;v=4.5;clr=4.0.30319.34014;bit=64;os=Microsoft Windows NT 6.2.9200.0)
Authorization: Bearer A015NObhWZJY-ZZHdSmMvYL7GFA6A-pY7pK4zV1J8wysWJE
PayPal-Request-Id: 98a56a18-2306-4301-a366-e53a5db54536
Host: api.sandbox.paypal.com
Content-Length: 246
Expect: 100-continue
{"name":"plan \"PN123\" subscription","description":"plan \"PN123\" subscription with payments every 12 months.","start_date":"2015-02-06T16:58:56z","payer":{"payment_method":"paypal"},"plan":{"id":"P-2Y404528U1543832BL7HBW6A"}}
Pretty Request Json
{
"name":"A plan \"PN123\" subscription",
"description":"plan \"PN123\" subscription with payments every 12 months.",
"start_date":"2015-02-06T16:58:56z",
"payer":{
"payment_method":"paypal"
},
"plan":{
"id":"P-2Y404528U1543832BL7HBW6A"
}
}
Response
HTTP/1.1 201 Created
Server: Apache-Coyote/1.1
PROXY_SERVER_INFO: host=slcsbplatformapiserv3001.slc.paypal.com;threadId=374466
Paypal-Debug-Id: 739b28e849ee7
SERVER_INFO: paymentsplatformserv:v1.payments.billing-agreements&CalThreadId=501225&TopLevelTxnStartTime=14b5fce3a78&Host=slcsbpaymentsplatformserv3001.slc.paypal.com&pid=22725
Content-Language: *
Date: Fri, 06 Feb 2015 16:52:05 GMT
Content-Type: application/json
Content-Length: 1174
Pretty json from response
{
"name":"plan \"PN123\" subscription",
"description":"plan \"PN123\" subscription with payments every 12 months.",
"plan":{
"id":"P-2Y404528U1543832BL7HBW6A",
"state":"ACTIVE",
"name":"PN123",
"description":"plan \"PN123\" subscription",
"type":"INFINITE",
"payment_definitions":[
{
"id":"PD-8RD12495MY6350633L7HBW6I",
"name":"Regular Payments",
"type":"REGULAR",
"frequency":"Month",
"amount":{
"currency":"USD",
"value":"20"
},
"cycles":"0",
"charge_models":[
],
"frequency_interval":"12"
}
],
"merchant_preferences":{
"setup_fee":{
"currency":"USD",
"value":"0"
},
"max_fail_attempts":"0",
"return_url":"http://example.com/Subscription/Renew.aspx?result=ApproveAgreement",
"cancel_url":"http://example.com/Subscription/Renew.aspx?result=CancelAgreement",
"auto_bill_amount":"NO",
"initial_fail_amount_action":"CONTINUE"
}
},
"links":[
{
"href":"https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-4R936998H4630535M",
"rel":"approval_url",
"method":"REDIRECT"
},
{
"href":"https://api.sandbox.paypal.com/v1/payments/billing-agreements/EC-4R936998H4630535M/agreement-execute",
"rel":"execute",
"method":"POST"
}
],
"start_date":"2015-02-06T16:58:56z"
}
You will get the Id when the payment gets executed, on paypal as your payment type.
Create Billing Agreement. You will get an EC-Token, and URL
On Success, Execute Billing Agreement, and
You could run the samples attached with the PayPal-PHP-SDK, to try out before implementing the code yourself. Also, most of the sample code could be copy-pasted to get started easily.
Here are the screen shots from the samples:
1. Created Agreement. Use the URL pointed in dark black line
2. Executed Agreement. As you can see, it has the agreement ID.

Google cloud storage objective c sample

I got the Google API for Objective C for using Cloud Storage Module from below path.
Google API Objective-C Client
Unluckily the api didn't provide any Sample Code for Cloud Storage so I tried to do it myself but I couldn't be successful. Below is what I am doing
I enabled my billing for Cloud Storage from Google API Console
I made a bucket with name "ahs_test"
I made a Client ID for installed applications
I got successful with Outh2.0 with the library available at upper SVN Path. After doing this I wrote below code and get below error message
Note that After reading Google Cloud Storage I am sort of sure that I have to send the "x-goog-project-id" in my request header but I am wondering that this API's code doesn't do anything like that. ( I might be doing some mistake so leaving this for getting any sort of help.. Thanks in Advance...)
// Code....
GTLServiceStorage *service = self.storageService
GTLQueryStorage *query = [GTLQueryStorage queryForBucketsGetWithBucket:#"ahs_test"];
_fileListTicket = [service executeQuery:query
completionHandler:^(GTLServiceTicket *ticket,
GTLStorageBuckets *bucketList,
NSError *error) {
}];
// Error Message I get (Detailed from loger)
storage.buckets.get
2012-12-30 07:11:30 +0000
Request: POST https://www.googleapis.com/rpc?prettyPrint=false
Request headers:
Accept: application/json-rpc
Authorization: Bearer _snip_
Cache-Control: no-cache
Content-Type: application/json-rpc; charset=utf-8
User-Agent: com.example.DriveSample/1.0 google-api-objc-client/2.0 MacOSX/10.8 (gzip)
Request body: (128 bytes)
{
"jsonrpc" : "2.0",
"method" : "storage.buckets.get",
"id" : "gtl_3",
"params" : {
"bucket" : "ahs_test",
"max-results" : 150
},
"apiVersion" : "v1beta1"
}
Response: status 200
Response headers:
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Content-Encoding: gzip
Content-Length: 132
Content-Type: application/json; charset=UTF-8
Date: Sun, 30 Dec 2012 07:10:44 GMT
Expires: Fri, 01 Jan 1990 00:00:00 GMT
Pragma: no-cache
Server: GSE
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
Response body: (168 bytes)
{
"error" : {
"message" : "Access Not Configured",
"data" : [
{
"reason" : "accessNotConfigured",
"message" : "Access Not Configured",
"domain" : "usageLimits"
}
],
"code" : 403
},
"id" : "gtl_3"
}
The Google API library uses the Cloud Storage JSON API, which isn't enabled by default. Please check to see if it is enabled in the Google APIs console.