Google Realtime API update model from JSON

淺唱寂寞╮ 提交于 2019-12-11 02:52:51

问题


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;
}

来源:https://stackoverflow.com/questions/31052768/google-realtime-api-update-model-from-json

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!