2

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;
}
samsamm777
  • 1,648
  • 2
  • 14
  • 14
  • Are you using the correct app id to to make the request? You could verify by doing a get, using the same credentials and doc id: do you get the document you expect? – Cheryl Simon Jun 26 '15 at 16:22
  • @CherylSimon can confirm GET /drive/v2/files//realtime does work, and the response contains the real-time model. Also worth noting the PUT request has a 'result' property in the json which is FALSE. – samsamm777 Jul 01 '15 at 10:33
  • Maybe a stupid question, but you are sure that you are providing modified json? – Cheryl Simon Jul 01 '15 at 21:39
  • @CherylSimon Yes the json is definitely different. – samsamm777 Jul 02 '15 at 09:13
  • +1 for example code which actually does work for me. Finding any useful documentation on the realtime update REST API (or even gapi.client.request) is like hunting fish with feet. And shoes. – HeyHeyJC Mar 06 '16 at 19:02
  • Also +1 for this example, can confirm that it works for me (event if documentation confusingly says "Do not supply a request body with this method.") One thing I'm interested in is whether this API will be available after the RealTime API officially retires in 2019. – Jaroslav Benc Dec 24 '17 at 09:02

0 Answers0