Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gmail.users.watch() - Same call returns 500 & 200 #1639

Closed
e1um opened this issue Mar 15, 2019 · 4 comments
Closed

gmail.users.watch() - Same call returns 500 & 200 #1639

e1um opened this issue Mar 15, 2019 · 4 comments
Assignees
Labels
type: question Request for information or clarification. Not an issue.

Comments

@e1um
Copy link

e1um commented Mar 15, 2019

Environment details

  • OS: macOS Mojave 10.14.3
  • Node.js version: 10.0.0
  • npm version:6.9.0
  • googleapis version:^33.0.0

Steps to reproduce

  1. Initialize gmail libarary
google.gmail({version: 'v1', auth}
  1. Set params for call
const watchReq = {
    labelIds: [
      'CATEGORY_UPDATES',
      'DRAFT',
      'CATEGORY_PROMOTIONS',
      'CATEGORY_SOCIAL',
      'CATEGORY_FORUMS',
      'TRASH',
      'CHAT',
      'SPAM',
    ],
    labelFilterAction: 'exclude',
    topicName: '**************',

const params = {
  userId:'me', 
  requestBody: watchReq
}

gmail.users.watch(params)
  1. Response
response:
   { status: 500,
     statusText: 'Internal Server Error',
     headers:
      { vary: 'Origin, X-Origin',
        'content-type': 'application/json; charset=UTF-8',
        date: 'Fri, 15 Mar 2019 16:14:15 GMT',
        expires: 'Fri, 15 Mar 2019 16:14:15 GMT',
        'cache-control': 'private, max-age=0',
        'x-content-type-options': 'nosniff',
        'x-frame-options': 'SAMEORIGIN',
        'x-xss-protection': '1; mode=block',
        server: 'GSE',
        'alt-svc': 'quic=":443"; ma=2592000; v="46,44,43,39"',
        connection: 'close',
        'transfer-encoding': 'chunked' },
     config:
      { adapter: [Function: httpAdapter],
        transformRequest: [Object],
        transformResponse: [Object],
        timeout: 0,
        xsrfCookieName: 'XSRF-TOKEN',
        xsrfHeaderName: 'X-XSRF-TOKEN',
        maxContentLength: 2147483648,
        validateStatus: [Function],
        headers: [Object],
        method: 'post',
        url: 'https://www.googleapis.com/gmail/v1/users/me/watch',
        paramsSerializer: [Function],
        data: '{"labelIds":["CATEGORY_UPDATES","DRAFT","CATEGORY_PROMOTIONS","CATEGORY_SOCIAL","CATEGORY_FORUMS","TRASH","CHAT","SPAM"],"labelFilterAction":"exclude","topicName":"******************"}',
        params: {} },
     request:
      ClientRequest {
        _events: [Object],
        _eventsCount: 6,
        _maxListeners: undefined,
        output: [],
        outputEncodings: [],
        outputCallbacks: [],
        outputSize: 0,
        writable: true,
        _last: true,
        chunkedEncoding: false,
        shouldKeepAlive: false,
        useChunkedEncodingByDefault: true,
        sendDate: false,
        _removedConnection: false,
        _removedContLen: false,
        _removedTE: false,
        _contentLength: null,
        _hasBody: true,
        _trailer: '',
        finished: true,
        _headerSent: true,
        socket: [TLSSocket],
        connection: [TLSSocket],
        _header: 'POST /gmail/v1/users/me/watch HTTP/1.1\r\nAccept: application/json, text/plain, */*\r\nContent-Type: application/json;charset=utf-8\r\nAccept-Encoding: gzip\r\nUser-Agent: google-api-nodejs-client/0.2.1 (gzip)\r\nAuthorization: Bearer **************\r\nContent-Length: 210\r\nHost: www.googleapis.com\r\nConnection: close\r\n\r\n',
        _onPendingData: [Function: noopPendingOutput],
        agent: [Agent],
        socketPath: undefined,
        timeout: undefined,
        method: 'POST',
        path: '/gmail/v1/users/me/watch',
        _ended: true,
        res: [IncomingMessage],
        aborted: undefined,
        timeoutCb: null,
        upgradeOrConnect: false,
        parser: null,
        maxHeadersCount: null,
        _redirectable: [Writable],
        [Symbol(isCorked)]: false,
        [Symbol(outHeadersKey)]: [Object] },
     data: { error: [Object] } },
  code: 500,
  errors:
   [ { domain: 'global',
       reason: 'backendError',
       message: 'Backend Error' } ] }

I'll run it multiple times in a row and sometimes it'll return 200 and sometimes it'll return this 500 error. I'm not hitting my API usage limits. Also it would return a 4xx if I was right?

Any help is much appreciated. Thanks!

@JustinBeckwith JustinBeckwith added the type: question Request for information or clarification. Not an issue. label Mar 15, 2019
@ghmeier
Copy link

ghmeier commented Mar 18, 2019

@e1um, are you running the same requests with different authentication or for different users? If so, it's possible you're running into this bug: #1594.

@e1um
Copy link
Author

e1um commented Mar 19, 2019 via email

@vishald123
Copy link

Hi, @e1um You can try the following way. Let me know if it works for you.

const gmail = await google.gmail({ version: 'v1', auth: auth });
        await gmail.users.watch({ userId: 'me',
          requestBody: {
            topicName: `projects/test/topics/test`,
          },
          labelIds: [
            'CATEGORY_UPDATES',
            'DRAFT',
            'CATEGORY_PROMOTIONS',
            'CATEGORY_SOCIAL',
            'CATEGORY_FORUMS',
            'TRASH',
            'CHAT',
            'SPAM',
           ],
          labelFilterAction: 'exclude'
       })
        .then(function(res) {
            console.log(res.data);
        }).catch( function(err) {
            console.log(err);
        })
  };

@bcoe
Copy link
Contributor

bcoe commented Apr 4, 2019

@e1um were you able to try @vishald123's recommendation?

Are you continuing to bump into issues.

@JustinBeckwith JustinBeckwith self-assigned this Feb 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

5 participants