Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to access data from Google Data Store Using Anguarjs $Http POST Request?

I have Tried and below is my code i don't know what went wrong

$http({
  method: 'POST',
  headers:'{"gqlQuery": {"queryString": "select * from culture" }}',
  url: 'https://datastore.googleapis.com/v1/projects/nammaooru-3630e:runQuery?fields=batch%2Cquery&key=[myapikey]'
}).then(function successCallback(response) {

  alert("Success"+response);
    // this callback will be called asynchronously
    // when the response is available
  }, function errorCallback(response) {
    alert("Error"+response);
    // called asynchronously if an error occurs
    // or server returns response with an error status.
  });

Got Error in angular Request**

https://datastore.googleapis.com/v1/projects/nammaooru-3630e:runQuery?fields=batch%2Cquery&key=[apikey]

Failed to load resource: the server responded with a status of 401 ()

Got Error while trying in Postman

URL : https://datastore.googleapis.com/v1/projects/nammaooru-3630e:runQuery?fields=batch%2Cquery&key=[apikey]

Method : POST 


    {
      "error": {
        "code": 401,
        "message": "The request does not have valid authentication credentials.",
        "status": "UNAUTHENTICATED"
      }
    }

But I got out put response from Google Developer site

https://cloud.google.com/datastore/docs/reference/rest/v1/projects/runQuery#http-request

{
 "batch": {
  "entityResultType": "FULL",
  "entityResults": [
   {
    "entity": {
     "key": {
      "partitionId": {
       "projectId": "nammaooru-3630e"
      },
      "path": [
       {
        "kind": "culture",
        "id": "5629499534213120"
       }
      ]
     },
     "properties": {
      "types": {
       "stringValue": "",
       "excludeFromIndexes": true
      },
      "images": {
       "stringValue": "",
       "excludeFromIndexes": true
      },
      "bname": {
       "stringValue": "Kangeyam Kalai"
      },
      "date": {
       "timestampValue": "2017-01-14T12:44:56.933Z"
      },
      "title": {
       "stringValue": ""
      },
      "description": {
       "stringValue": "Coimbatore Kongu nadu region",
       "excludeFromIndexes": true
      }
     }
    },
    "cursor": "Ci8SKWoRc35uYW1tYW9vcnUtMzYzMGVyFAsSB2N1bHR1cmUYgICAgICAgAoMGAAgAA==",
    "version": "1484398012256000"
   }
  ],
  "endCursor": "Ci8SKWoRc35uYW1tYW9vcnUtMzYzMGVyFAsSB2N1bHR1cmUYgICAgICAgAoMGAAgAA==",
  "moreResults": "NO_MORE_RESULTS"
 },
 "query": {
  "kind": [
   {
    "name": "culture"
   }
  ]
 }
}
like image 270
Gopinath Kaliappan Avatar asked Jan 19 '17 18:01

Gopinath Kaliappan


1 Answers

--disable-web-security and restart the chrome by run below command in window "Run":

chrome --allow-file-access-from-files --disable-web-security --user-data-dir
like image 150
Priyank Avatar answered Oct 24 '22 14:10

Priyank