Skip to content

batch commands in 0.4.1 #75

@afirstenberg

Description

@afirstenberg

Commands that are called using a direct command work, while using the same command with the batch commands fail.

For example, this function sets up a client mirror subscription command (in a module later required as "glass"):

exports.subscribeGlassCallbacksCmd = function( user ){
  var baseUrl = exports.BASE_URL;
  var subscribeUrl = baseUrl+"/incoming/callback";
  if( subscribeUrl.indexOf("http:") === 0 ){
    subscribeUrl = "https://mirrornotifications.appspot.com/forward?url="+subscribeUrl;
  }

  // Subscribe to updates from Glass
  var subscription = {
    collection: "timeline",
    callbackUrl: subscribeUrl,
    userToken: user.id
  };
  console.log( 'subscribeGlassCallbacksCmd', subscription );

  var cmd = client.mirror.subscriptions.insert(subscription);
  return cmd;
};

Calling it directly using these commands appear to work:

    var subc = glass.subscribeGlassCallbacksCmd(req.user);
    subc.withAuthClient(req.user.auth).execute(function(err,result){
      console.log( 'subc', err, result );
    });

err is null and result is set to the JSON representing the subscription:

subc null { kind: 'mirror#subscription',
  id: 'timeline',
  updated: '2013-08-06T11:33:56.772Z',
  collection: 'timeline',
  callbackUrl: 'https://prisoner.com/dev/glass-drive/incoming/callback',
  userToken: '101852559274654726533' }

Calling it using the following batch commands, however, don't:

    var batch = client.newBatchRequest();
    batch.add( glass.subscribeGlassCallbacksCmd(req.user) );
    batch.withAuthClient(req.user.auth).execute(cb);

the error that gets returned is

{ errors: 
   [ { domain: 'global',
       reason: 'required',
       message: 'collection field is required for Subscription' },
     { domain: 'global',
       reason: 'required',
       message: 'callbackUrl field is required for Subscription' } ],
  code: 400,
  message: 'collection field is required for Subscription' }

I've tried other combinations of the parameters to the call to list, but they don't appear to work any better.

Metadata

Metadata

Assignees

Labels

🚨This issue needs some love.triage meI really want to be triaged.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions