Skip to content

I am experiencing issues using 1.5.2. #152

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

Closed
muthurathinam opened this issue Mar 14, 2019 · 6 comments
Closed

I am experiencing issues using 1.5.2. #152

muthurathinam opened this issue Mar 14, 2019 · 6 comments

Comments

@muthurathinam
Copy link
Contributor

I am also experiencing issues using 1.5.2.

Description

API calls using 1.5.2 fail with "Response is not defined". In my case, this is true whether using API version "v1.0" or "beta". Here are the calls I am making and the (same) resultant error that is produced after each.

const { Client } = require('@microsoft/microsoft-graph-client');

class SimpleGraphClient {
    constructor(token) {
        if (!token || !token.trim()) {
            throw new Error('SimpleGraphClient: Invalid token received.');
        }

        this._token = token;

        // Get an Authenticated Microsoft Graph client using the token issued to the user.
        this.graphClient = Client.init({
            authProvider: (done) => {
                done(null, this._token); // First parameter takes an error if you can't get an access token.
            }
        });
    }

    async sendMail(toAddress, subject, content) {
        if (!toAddress || !toAddress.trim()) {
            throw new Error('SimpleGraphClient.sendMail(): Invalid `toAddress` parameter received.');
        }
        if (!subject || !subject.trim()) {
            throw new Error('SimpleGraphClient.sendMail(): Invalid `subject`  parameter received.');
        }
        if (!content || !content.trim()) {
            throw new Error('SimpleGraphClient.sendMail(): Invalid `content` parameter received.');
        }

        const mail = {
            body: {
                content: content, // `Hi there! I had this message sent via MS Graph. - Your friend, ${ graphData.displayName }!`,
                contentType: 'Text'
            },
            subject: subject, // `Message from MS Graph!`,
            toRecipients: [{
                emailAddress: {
                    address: toAddress
                }
            }]
        };

        return await this.graphClient
            .api('/me/sendMail')
            .post({ message: mail }, (error, res) => {
                if (error) {
                    throw error;
                } else {
                    return res;
                }
            });
    }

    async getRecentMail() {
        return await this.graphClient
            .api('/me/messages')
            .version('v1.0')
            .top(5)
            .get()
            .then((res) => {
                return res;
            })
            .catch((err) => {
                console.log(err);
            });
    }

    async getMe() {
        return await this.graphClient
            .api('/me')
            .version('v1.0')
            .get()
            .then((res) => {
                console.log(res);
                return res;
            })
            .catch((err) => {
                console.log(err);
            });
    }

    async getManager() {
        return await this.graphClient
            .api('/me/manager')
            .version('v1.0')
            .select('displayName')
            .get()
            .then((res) => {
                return res;
            })
            .catch((err) => {
                console.log(err);
            });
    }

    async getPhoto() {
        return await this.graphClient
            .api('/me/photo/$value')
            .responseType('ArrayBuffer')
            .version('v1.0')
            .get()
            .then((res) => {
                return res;
            })
            .catch((err) => {
                console.log(err);
            });
    }
}

Downgrading to 1.4.0 and the API calls succeed.

Console Errors:

ReferenceError: Response is not defined
    at Function.<anonymous> (C:\...\node_modules\@microsoft\microsoft-graph-client\lib\src\GraphErrorHandler.js:127:48)
    at step (C:\...\node_modules\tslib\tslib.js:133:27)
    at Object.next (C:\...\node_modules\tslib\tslib.js:114:57)
    at C:\...\node_modules\tslib\tslib.js:107:75
    at new Promise (<anonymous>)
    at Object.__awaiter (C:\...\node_modules\tslib\tslib.js:103:16)
    at Function.GraphErrorHandler.getError (C:\...\node_modules\@microsoft\microsoft-graph-client\lib\src\GraphErrorHandler.js:122:24)
    at GraphRequest.<anonymous> (C:\...\node_modules\@microsoft\microsoft-graph-client\lib\src\GraphRequest.js:227:84)
    at step (C:\...\node_modules\tslib\tslib.js:133:27)
    at Object.throw (C:\...\node_modules\tslib\tslib.js:114:57)

Steps to Reproduce

  1. Install NPM package v1.5.2
  2. Make the API calls
  3. Observe the errors

Expected behavior:
Values should be returned via MS Graph for the various API calls.

Actual behavior:
Receive "Response is not defined" error.

Originally posted by @stevkan in #151 (comment)

@muthurathinam
Copy link
Contributor Author

muthurathinam commented Mar 14, 2019

@stevkan
It is working fine with my environment. can you help me in reproducing the issue by sharing your environment and its version ?

@muthurathinam muthurathinam changed the title I am also experiencing issues using 1.5.2. I am experiencing issues using 1.5.2. Mar 15, 2019
@bigthing33
Copy link

In my case:

  • node version:8.10.0 & microsoft-graph-client version: 1.5.2; error: Response is not defined
  • node version:8.10.0 & microsoft-graph-client version: 1.4.0; working fine
  • node version:10.5.3 & microsoft-graph-client version: 1.5.2; working fine

@Ricardonacif
Copy link

I just experienced some issues with version 1.5.2 and I had to rollback to 1.4.0. When I do the following call:

client
      .api(
        `/me/calendars/${calendarId}/calendarview?startDateTime=${start.toISOString()}&endDateTime=${end.toISOString()}`,
      )
      .top(8)
      .select('subject,start,end,attendees,body,location,organizer')
      .orderby('start/dateTime ASC')
      .get();

It is not returning the promise, never. I put some debugging console.log inside the library and I could see that the server was returning a 200 response with the proper calendar events data, but the promise never resolved. Went back to 1.4.0 and it all works again.

@stevkan
Copy link

stevkan commented May 31, 2019

@muthurathinam, apologies. I somehow missed your message to me way up above. It still does not work for me unless I use v1.0.0 (have tried up to v1.7.0). Please let me know if there is specific information you would like/need from me.

p.s. I'll keep this on my radar, this time around.

@muthurathinam
Copy link
Contributor Author

muthurathinam commented May 31, 2019

@stevkan can you help with this, just verify whether you are getting the same error that you have mentioned here.

ReferenceError: Response is not defined
    at Function.<anonymous> (C:\...\node_modules\@microsoft\microsoft-graph-client\lib\src\GraphErrorHandler.js:127:48)
    at step (C:\...\node_modules\tslib\tslib.js:133:27)
    at Object.next (C:\...\node_modules\tslib\tslib.js:114:57)
    at C:\...\node_modules\tslib\tslib.js:107:75
    at new Promise (<anonymous>)
    at Object.__awaiter (C:\...\node_modules\tslib\tslib.js:103:16)
    at Function.GraphErrorHandler.getError (C:\...\node_modules\@microsoft\microsoft-graph-client\lib\src\GraphErrorHandler.js:122:24)
    at GraphRequest.<anonymous> (C:\...\node_modules\@microsoft\microsoft-graph-client\lib\src\GraphRequest.js:227:84)
    at step (C:\...\node_modules\tslib\tslib.js:133:27)
    at Object.throw (C:\...\node_modules\tslib\tslib.js:114:57)

Also, you have mentioned that Downgrading to 1.4.0 and the API calls succeed (in the issue description) but this contradicts your above comment can you please clear things out for me.

FYI: This is autoclosed when I did mention the issue in the PR and also the fix is not released yet. will post here once its released.

@stevkan
Copy link

stevkan commented Jun 1, 2019

@muthurathinam, apologies for the confusion.

Yes, I am still receiving the above error using version 1.5.2. Using version 1.4.0 does work (I believe that was a typo - 1.0.0 should have been 1.4.0).

As an aside, when I try version 1.7.0 I get the following error (happy to log as a new issue):

GraphError {
  statusCode: -1,
  code: null,
  message: null,
  requestId: null,
  date: 2019-06-01T03:11:38.904Z,
  body: null }

 [onTurnError]: TypeError: Cannot read property 'displayName' of undefined

The 'onTurnError' text can be ignored. The important part is the reference to 'displayName' which occurs when trying to authenticate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants