Google Realtime API update model from JSON

138 Views Asked by At

I'm having trouble utilising the /realtime/update rest resource. I can successfully make the request as specified in the docs and i get a 204 status response with no body. Which is expected. However the realtime model in my application does not change in anyway. Am I missing something on how the resource works?

this.updateRealtimeWithRevision = function (fileId, revisionId) {
  var deferred = $q.defer();

  var onComplete = function (result) {
    deferred.resolve(result);
    $rootScope.$digest();
  };

  // get revision content...
  this.load(fileId, revisionId).then(function(data){

    var json = angular.toJson(data);

    var request = {
      'path': '/upload/drive/v2/files/' + fileId + '/realtime',
      'method': 'PUT',
      'headers': {
        'Content-Type': 'application/json'
      },
      'params': {
        'uploadType': 'media'
      } ,
      'body': json
    };

    console.log(request);

    gapi.client.request(request).then(
      function(resp){
        console.log("fullfilled");
        console.log(resp);
      },
      function(resp){
        console.log("reject");
        console.log(resp);
      }
    );

  });

  return deferred.promise;
}
0

There are 0 best solutions below