Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Anuj Kumar Pal
    @Anujkmrpal
    3.png
    @koltyakov can you tell what is wrong with restcondition in this as the result is not as per restcondition
    Andrew Koltyakov
    @koltyakov
    @Anujkmrpal
    Was able to check and metaFields work together with camlCondition nicely. Regarding restCondition, my bad I've forgotten that I abandoned the idea for bypassing REST conditions (there was an interface for that by no handler).
    But, confirming CAML+Metadata extraction should work just fine.
    image.png
    Anuj Kumar Pal
    @Anujkmrpal
    @koltyakov You Didn't use spDocLibUrl which i think mendatory with camlCondition, So camlCondition didn't work in your case only metaFields works thats why it shows metaData
    correct me if i am wrong
    Andrew Koltyakov
    @koltyakov
    Fair point. Sorry, I missed this out. It was really a bug with getting metadata with CAML, fixed, publishing a version.
    image.png
    Please check with sppull@2.6.1
    Anuj Kumar Pal
    @Anujkmrpal
    @koltyakov Thanks working now
    Andrew Koltyakov
    @koltyakov
    Happy codding!
    paulinedahneaspire
    @paulinedahneaspire

    sp-rest-proxy help please
    I am trying to set up a dev enviroment but cannot get SharePoint Online auth working.
    npm install sp-rest-proxy --save-dev
    server.js
    const RestProxy = require('sp-rest-proxy');

    const settings = {
    configPath: './config/private.json', // Location for SharePoint instance mapping and credentials
    port: 8080, // Local server port
    staticRoot: './static' // Root folder for static content
    };

    const restProxy = new RestProxy(settings);
    restProxy.serve();

    paulinedahneaspire
    @paulinedahneaspire
    when I run npm run serve and enter the SharePoint url, name and password the proxy runs successfully. However when the SharePoint Online project starts up on http://localhost with npm run start I am unable to retrieve the SharePoint Online data. There is no error message - just a progress wheel however when I use the browser inspect tool the first error under the Network tab is
    Request URL: https://xxxxxxxxxxxxxx.sharepoint.com/sites/CMDev/_api/web/currentuser error 403
    x-msdavext_error: 917656; Access+denied.+Before+opening+files+in+this+location%2c+you+must+first+browse+to+the+web+site+and+select+the+option+to+login+automatically.
    The error message is always the same - permission denied. It appears that the SAML token is not being passed through to npm run start
    Andrew Koltyakov
    @koltyakov
    Hi @paulinedahneaspire, in a local workbench you have to route requests not to SharePoint URL but proxy endpoint. http://localhost:8080/sites/CMDev.
    paulinedahneaspire
    @paulinedahneaspire
    Thank you for you very quick reply. So do I need to edit the exportsiteurl.js to point to http://localhost as opposed to https://xxxxxx.sharepoint.com/sites/cmdev ? If so do I include the port :8080 in the exportsiterurl.js ? Thank you
    Andrew Koltyakov
    @koltyakov
    Have no idea what's exportsiteurl.js. Custom config within your particular app I guess. There are two techniques: one is conditionally switching endpoint URL (on localhost condition, similar as this helper does) or providing local server (WebPack Dev server, for instance, has API proxy setting) an extra setting to route to sp-rest-proxy. First one is simpler in configuration, though not so sophisticated as configuring workbench.
    I'm wondering, what's is used for local serve?
    paulinedahneaspire
    @paulinedahneaspire
    Thank you again. As you may have guessed I am not the developer. I am a SharePoint specialist that has been asked to setup a dev environment for a React project that has been developed by consultant that we can no longer get hold of. I am following the instructions he has left but they appear to be lacking
    Andrew Koltyakov
    @koltyakov
    On my projects, I mostly prefer extending WebPack Dev server config with sp-rest-proxy. So serve command actually starts only one server. As a scaffolding example, generator-sppp shows how it could be configured. It provides the configuration right OOTB. Yet, if one prefers CRA or used to a specific framework configuration, sppp is better to be used as a sample to grab some code from.
    Andrew Koltyakov
    @koltyakov
    Something to add, SPPP is for the projects which are in between of SPO and On-Prem. And for the folks who consider simplifying transitioning from classic to modern dev, of got to stick for some time with classic but do it in a more robust way. For SPO, I'd suggest considering Modern and SPFx. With SPFx, sp-rest-proxy can be used, however, there is a common way of opening SPFx webpart in SP hosted workbench or using SPFx debug mode.

    has been developed by consultant that we can no longer get hold of. I am following the instructions he has left but they appear to be lacking

    It can be so many moving parts and opinionated decisions.

    paulinedahneaspire
    @paulinedahneaspire
    Thank you again. Your first response was extremely useful. I have edited the exporturl file to point to localhost:8081 and all is working! :-)
    Andrew Koltyakov
    @koltyakov
    Cool! Glad it works now. Good luck on the project. It's always a pain when somebody left the gaps.
    michaelcmelton
    @michaelcmelton
    Hey, all. New to interacting with the SP REST API. I've build a function that retrieves the data via ajax, and a separate "main" function that runs all the calls. Is there an easy way for me to pass variables between the two functions without calling global variables and muddying the waters on the window object? In particular, I'm trying to dynamically build a JSON file with the data as I'm looping through it, and at the end read the JSON to a new file. Hopefully that makes sense.
    Andrew Koltyakov
    @koltyakov
    Hey @michaelcmelton, what you ask is not about REST API at all, but JavaScript topic in general (as no dependency to SharePoint any JS materials could be relevant). I’d suggest checking how dealing with async dev in JS and Promises in particular. Storing anything in the global scope is anti-pattern which should be avoided (and in 99% it’s just not needed) until you know what you do. It’s better following functional approach passing result from one function to another using arguments.
    michaelcmelton
    @michaelcmelton
    @koltyakov, thanks for the response. I was able to wrap everything inside an IIFE and keep scope away from the global. I do have a question about the REST API though. When I make a POST Request with requested field creation data, analyzing the response data puts me off, as it doesn't align with what I sent in the body. But a GET request to the newly created field ID yields the exact response I intially expected. Screenshots below for context, particularly focus on the Group field. Any thoughts?
    michaelcmelton
    @michaelcmelton
    HIrwaniJain
    @HIrwaniJain
    Hi
    Error: File not found with singular glob: D:/hirwani/PForm/SharePoint-Site-Request-Form_28082018/SharePoint-Site-Request-Form/typings/main.d.ts (if this was purposeful, use allowEmpty option)
    at Glob.<anonymous> (D:\hirwani\PForm\SharePoint-Site-Request-Form_28082018\SharePoint-Site-Request-Form\node_modules\gulp\node_modules\glob-stream\readable.js:84:17)
    Can someone help me with this issue ?
    this is coming after gulp build
    Just trying to reopen one of the old project (built 2 years ago by someone else )
    Ricardo Dias
    @slowdata
    Hi, can someone please help me connect to on premise Sharepoint. I'm getting 401 - Undefined and can't figure out whats the problem
    Ricardo Dias
    @slowdata
    Can someone put me in some kind of direction?
    Andrew Koltyakov
    @koltyakov
    Hi Ricardo, I’d suggest providing more details. What’s the version os SharePoint, what auth strategy it uses and what parameters are you providing. https://github.com/koltyakov/node-sp-auth-troubleshoot can be helpful for scoping auth related issues.
    Ricardo Dias
    @slowdata
    Hi Andrew, thkx
    I never work with integrating nothing to Sharepoint.
    I have a node application to extract some files from Sql server and now i'm implementing the functionality to upload them to a List in Sahrepoint
    I using node-sp-auth to authenticate
    Its a on premises Sharepoint (version 2016)
    The authentication with user password return the Authentication token: NTLM <token>
    Ricardo Dias
    @slowdata
    I think as it's suppose to. Then I tried to make another call (trying to get the Sites Lists) and always get 401
    Andrew Koltyakov
    @koltyakov
    How do you send a request to API? Do you use what node-sp-auth returned in the calls?
    Ricardo Dias
    @slowdata
    yes
    The result in the .getAuth looks goo.

    {
    headers: {
    Connection: 'Close',
    Authorization: 'NTLM TlRMTVNTUAADAAAAGAAYAEAAAADqAOoAWAAAAAkACQBCAQAADgAOAEsBAAALAAsAWQEAAAAAAAAAAAAABoKJAs98GvVVaGG2yLYfeWzsfmpI6Uk2XnJ2AkQWr5sblQlSxNsTTxUs/nABAQAAAAAAABBfMSfWDNYBSOlJNl5ydgIAAAAAAgASAFMARQBHAFMATwBDAEkAQQBMAAEAFABTAFIAVgA0ADAAQQBQAFAAMgA4AAQAHgBzAGUAZwBzAG8AYwBpAGEAbAAuAGwAbwBjAGEAbAADADQAUwBSAFYANAAwAEEAUABQADIAOAAuAHMAZQBnAHMAbwBjAGkAYQBsAC4AbABvAGMAYQBsAAUAHgBzAGUAZwBzAG8AYwBpAGEAbAAuAGwAbwBjAGEAbAAHAAgAzTYlJ9YM1gEAAAAAAAAAAHNlZ3NvY2lhbHJpY2FyZG8udi5kaWFzSUlFUzI2Ri0xMTU='
    },
    options: {
    agent: Agent {
    _events: [Object: null prototype],
    _eventsCount: 2,
    _maxListeners: undefined,
    defaultPort: 80,
    protocol: 'http:',
    options: [Object],
    requests: {},
    sockets: {},
    freeSockets: [Object],
    keepAliveMsecs: 1000,
    keepAlive: true,
    maxSockets: Infinity,
    maxFreeSockets: 256,

      [Symbol(kCapture)]: false
    }

    }
    }

    then with gd-sprest a do this:

    .then((data) => {
    console.log(data);

    const info = $REST.Web(url).Lists("Tiago").getInfo();
    info.headers["Authorization"] = data.headers.Authorization;
    
    
    request({
      method: info.method,
      headers: info.headers,
      uri: info.url,
      json: true,
    })
      .then((res) => console.log("»»» ", JSON.parse(res).d))
      .catch((err) => console.log(">>> ", err));

    });

    I'm don't even now it our sharepoint is ready to use the API. And also the correct endpoints
    Andrew Koltyakov
    @koltyakov
    Don’t know what this rest client. Headers is not the only thing needed for a call with NTLM. Please try sp-request if it can fetch anything in your env without auth issues.