Getting the error - " Client is not defined "

Gabriel Costa 1 Reputation point
2021-02-24T15:49:08.957+00:00

Hello guys, Im new at Microsoft Graph and Im trying to use it to create new users (Im a tester/developer writing code for cypress). I adapted the following code from one of the Microsoft Graph pages: const options = { token, }; const client = Client.init(options); const user = { accountEnabled: true, displayName: "Adele Vance", mailNickname: "AdeleV", userPrincipalName: "AdeleV@Company portal .onmicrosoft.com", "passwordProfile" : { forceChangePasswordNextSignIn: true, password: "xWwvJ]6NMw+bWH-d" } }; let res = client.api('/users') .post(user); but when I run it with cypress, i get the error: " Client is not defined " which would look to me that its missing a library. So, I did some research on what microsoft graph uses as library and came up with this page: https://github.com/microsoftgraph/msgraph-sdk-javascript and followed the instructions to install the libraries on Visual Studio Code (javascript). I used this line: npm install @microsoft/microsoft-graph-client and then added this to commands,js : import "isomorphic-fetch"; import { Client } from "@microsoft/microsoft-graph-client"; I'm still getting the same error = " Client is not defined " What am I missing? Thanks!

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,647 questions
{count} votes