Gert Cuykens
Gert Cuykens

Reputation: 7175

google datastore api explorer example

I am trying to understand

https://developers.google.com/apis-explorer/#p/datastore/v1beta1/datastore.datasets.blindWrite

but I always get

503 Service Unavailable

{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "backendError",
    "message": "Backend Error"
   }
  ],
  "code": 503,
  "message": "Backend Error"
 }
}

Can you provide a example as simple as possible I can paste to verify it actually works? I tried something like this.

{
 "mutation": {
  "insertAutoId": [
   {
    "key": {
     "path": [
      {
       "kind": "person",
       "name": "gert"
      }
     ]
    }
   }
  ]
 }
}

Upvotes: 0

Views: 1550

Answers (1)

proppy
proppy

Reputation: 10504

Assuming that you followed one of the first two activation flows described in the documentation. And created the project recently, an App Engine application should be already associated with your project.

You need to:

  • Click Authorize your request using OAuth 2.0
  • Leave https://www.googleapis.com/auth/userinfo.email scope checked
  • Add https://www.googleapis.com/auth/datastore under Add additional scopes (optional)
  • Click Authorize and grant the permission
  • Specify the datasetId parameter (same as your project-id)
  • Use insert or upsert instead of insertAutoId if the key is complete (kind w/ name or id).

Example:

POST https://www.googleapis.com/datastore/v1beta1/datasets/my-dataset-id/blindWrite...

Content-Type:  application/json
Authorization:  Bearer ...
X-JavaScript-User-Agent:  Google APIs Explorer

{
 "mutation": {
  "insert": [
   {
    "key": {
     "path": [
      {
       "kind": "Foo",
       "name": "iamfoo"
      }
     ]
    }
   }
  ]
 }
}

200 OK

{
 "kind": "datastore#blindWriteResponse",
 "mutationResult": {
  "indexUpdates": 1
 }
}

Upvotes: 2

Related Questions