You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Aug 12, 2024. It is now read-only.
Hi Guys,
I am following the Andrei Markeev article - (https://markeev.com/posts/jsom-azure-function/), and using csom-node in my azure function to connect with sharepoint. the AuthenticationContext method is successful and able to connect to sharepoint site using appid and appsecret. But after that in the line where we are creating the clientContext using new SP.ClientContext("url"), i am getting the error unable to find ClientContext of undefined. In all the example code, the SP object is used without any imports or requires entry. Can you guys please advise how i can resolve the issue?
I tries to use an import statement
import {SP} from "csom-node";
if i use the statement, i am able to build and debug the function. (I am using VS Code). When i debug, I am able to see the SP object and if expanded, i can also see the ClientContext function under that. but if i continue the execution, the error Cannot read property 'ClientContext' of undefined
const csomApi = require("csom-node");
const AuthenticationContext = require('csom-node').AuthenticationContext;
csomapi.setLoaderOptions({url: settings.url}); //set CSOM library settings
var authCtx = new AuthenticationContext(settings.url);
authCtx.acquireTokenForUser(process.env.username, settings.password, function (err, data) {
**var ctx = new SP.ClientContext("/"); //set root web**
authCtx.setAuthenticationCookie(ctx); //authenticate
//retrieve SP.Web client object
var web = ctx.get_web();
ctx.load(web);
ctx.executeQueryAsync(function () {
Hi Guys,
I am following the Andrei Markeev article - (https://markeev.com/posts/jsom-azure-function/), and using csom-node in my azure function to connect with sharepoint. the AuthenticationContext method is successful and able to connect to sharepoint site using appid and appsecret. But after that in the line where we are creating the clientContext using new SP.ClientContext("url"), i am getting the error unable to find ClientContext of undefined. In all the example code, the SP object is used without any imports or requires entry. Can you guys please advise how i can resolve the issue?
I tries to use an import statement
import {SP} from "csom-node";
if i use the statement, i am able to build and debug the function. (I am using VS Code). When i debug, I am able to see the SP object and if expanded, i can also see the ClientContext function under that. but if i continue the execution, the error
Cannot read property 'ClientContext' of undefined
});
The text was updated successfully, but these errors were encountered: