Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Obe Lahnkara
    @Oberothton_twitter
    how do i delete a list item using sp-request? setting X-HTTP-Method to DELETE and setting url to _api/web/lists/getByTitle('Holiday')/items({ID}) doesnt seem to work
    i'm getting a 200 response but the item doesn't delete
    Obe Lahnkara
    @Oberothton_twitter
    @koltyakov sorry for ping but ^do you know how to do this?
    Andrew Koltyakov
    @koltyakov
    This works for me:
    const { AuthConfig } = require('node-sp-auth-config');
    const { create } = require('sp-request');
    
    (async () => {
    
      const { siteUrl, authOptions } = await new AuthConfig().getContext();
      const spr = create(authOptions);
    
      const digest = await spr.requestDigest(`${siteUrl}`);
      const res = await spr.post(`${siteUrl}/_api/web/lists/getByTitle('MyList')/items(1)`, {
        headers: {
          'X-RequestDigest': digest,
          'X-HTTP-Method': 'DELETE',
          'IF-MATCH': '*'
        }
      });
    
      console.log(res.statusCode, res.statusMessage);
    
    })().catch(console.warn);
    Obe Lahnkara
    @Oberothton_twitter
    spr.requestDigest(site).then(digest => {
    console.log(url);
    const headers = {
    'X-RequestDigest': digest,
    'X-HTTP-Method': 'DELETE',
    'IF-MATCH': '*'
    };
    spr.get(url).then(response => {
    let deleteUrl = ${site}/_api/web/lists/getByTitle('Holiday')/items(${response.body.d.results[0].ID});
                        spr.post(deleteUrl, { headers }).then(response => {
                            console.log(response.statusCode);
                        })
    this doesn't work for me. Strange.
    Obe Lahnkara
    @Oberothton_twitter
    doubly strange is upon execution i still receive a 200 OK response, which should mean the record is deleted, yet its not?
    Andrew Koltyakov
    @koltyakov
    Are you sure you aren’t deleting something else? ;D
    Obe Lahnkara
    @Oberothton_twitter
    i log the url after selecting the IDs and they seem to match the ids as seen in sharepoint, but maybe (i'm /very/ new to sharepoint lol)
    Obe Lahnkara
    @Oberothton_twitter
    it suddenly works now
    not sure why exactly haha
    Khanis Anthony K
    @khanisak

    hi guys, im new on sharepoint.
    im try to create sharepoint webpart with sharepoint framework.

    Can we call microsoft graph api on localhost workbench?

    Andrew Koltyakov
    @koltyakov
    Yes, you can, but got to create and configure AAD App Registration with redirect URI and some other none trivial things. So it's easier to run serve mode and debug a webpart on SharePoint page, so you can just use a default client ID.
    mctoastus
    @mctoastus
    Hi @koltyakov, a month ago i had a question. You told me to add something to the code.
    After doing that i get the following error:
    Error is: HTTPError: Response code 415 (Unsupported Media Type)
    Andrew Koltyakov
    @koltyakov
    @mctoastus what's the endpoint? The resource should obviously support the requested content type otherwise 415 is expected as the server can't resolve what to return.
    mctoastus
    @mctoastus
    If u mean what i want to access with the word endpoint, im trying to access sharepoint.
    Here is my code:
    https://i.imgur.com/snN1kyE.png
    Andrew Koltyakov
    @koltyakov
    image.png
    mctoastus
    @mctoastus
    Oh my god... hahaha
    mctoastus
    @mctoastus
    Mhm now it gives me a 400 (Bad Request) Error..
    Bruno Naibert
    @bruno-naibert
    Hello, I have a problem when trying to download a folder with images from sharepoint using sppull, what will it be?
    image.png
    Andrew Koltyakov
    @koltyakov
    Auth connected. Please make sure, that the auth strategy and creds are correct.
    Looks that the environment's strategy is not NTLM but something else.
    The simplest way to troubleshoot is https://github.com/koltyakov/node-sp-auth-troubleshoot
    Bruno Naibert
    @bruno-naibert
    I'll try that. But as I just want to get the path / URL of the images, without having to download them all, I would like to know if you have any more viable alternative? My initial plan would be to download all files in the same structure as the library and with Node.Js scan the folders and files on my computer to get only the URL / Path.
    Andrew Koltyakov
    @koltyakov
    I'd suggest PnPjs. But you have to have at least some understanding of what is SharePoint REST API.
    With REST, obviously, you can request a list/library and get metadata, filter only images, etc.
    ankitsaraswat27
    @ankitsaraswat27
    Hello, I am getting this error
    Access to XMLHttpRequest at 'https://waconafd.officeapps.live.com/apc/trans.gif?b320ab775852cec633df8395c6a55814' from origin 'https://abcd.sharepoint.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
    2 replies
    bradcurtis
    @bradcurtis
    I am looking to authenticate with a smart card. I was wondering if that is possible?
    1 reply
    Clint Lechner
    @clechner77
    @koltyakov I've been meaning to say something for a while, it looks like you have react listed twice in your default app.json. I assume one should be a dev version but they are both prod. Same path...
    Andrew Koltyakov
    @koltyakov
    @clechner77 thanks! It's a bug with presets. Fixed, will publish an update shortly.
    RickEvry
    @rickevry
    Hi, anyone managed to authenticate with MFA? I get "Due to a configuration change made by your administrator, or because you moved to a new location, you must use multi-factor authentication to access"
    Miguel Ángel González Muñoz
    @dactivo
    Hi, everyone, I have a problem with read permissions users in a site collection, I have tested and they can update his/her information in User Information List, using script, that is to say, they can change their email and their DisplayName/Title. Anyone know what's wrong or how to solve it?
    The script returns not authorized, but it updates the info: Even if the response from the request is a 403 not authorized:
    {"error":{"code":"-2147024891, System.UnauthorizedAccessException".....}

    Here you have the script in case you want to test it from chrome: var reqUrl= "https://XXXX.sharepoint.com/_api/web/siteusers/getbyid(170)";
    var body={ '__metadata':{ 'type': 'SP.Data.UserInfoItem' }, 'Title':'Active3','EMail': 'xxxx@xxx.es' }
    var _payloadOptions = {
    method: "POST",
    body: undefined,
    headers: {
    credentials: "include",
    Accept: "application/json; odata=verbose",
    "Content-Type": "application/json; odata=verbose"
    }
    };

    //Get RequestDigest First
    fetch("https://XXXX.sharepoint.com/_api/contextinfo",_payloadOptions).then(r=>r.json())
    .then(r=>
    {
    _payloadOptions.headers["X-RequestDigest"]=r.d.GetContextWebInformation.FormDigestValue
    _payloadOptions.headers["IF-MATCH"]="*"
    _payloadOptions.body=JSON.stringify(body);
    _payloadOptions.method="MERGE";
    // Make REST API Call to update list item without increamenting version.
    fetch(reqUrl
    ,_payloadOptions).then(function(r){

    console.log(r)
    }
    ).then(r=>console.log(r))
    })

    HeinnerXD
    @HeinnerXD
    Hi everyone, I used the "sppull" NPM package to download files from Sharepoint. But when the file is downloaded and I try to open it throw me an error:
    image.png
    Does anyone have the same error or any solution?
    Andrew Koltyakov
    @koltyakov
    Hi @HeinnerXD, responded to the issue on GitHub. Let's continue from there.
    Dardo
    @DardoJav
    Hi @koltyakov I was facing an issue trying to use the sppull api you provided (https://github.com/koltyakov/sppull) to download a shared excel file
    image.png
    I followed the example as you showed:
    with this response:
    Folders proceeding: 0 out of 0 [recursive scanning...]Core error has happened Error: Invalid argument
    Dardo
    @DardoJav
    also tried to specify the file:
    image.png
    with these response:
    Downloading files: 1 out of 1
    Error in operations.downloadFile: Invalid argument
    could you please help on this? don't know what I'm doing wrong here
    Andrew Koltyakov
    @koltyakov

    Hey @DardoJav,

    Please try with auth configurator to avoid incorrect creds payload:

    import { AuthConfig as SPAuthConfigurator } from 'node-sp-auth-config';
    import { ISPPullOptions, ISPPullContext, Download as IDownload } from 'sppull';
    
    new SPAuthConfigurator().getContext().then((context) => {
    
      const Download: IDownload = require('sppull');
      const sppull = Download.sppull;
    
      const context: ISPPullContext = {
        siteUrl: context.siteUrl,
        ...context.authOptions
      } as any;
    
      const options: ISPPullOptions = {
        spRootFolder: 'Shared%20Documents',
        dlRootFolder: './Downloads/Documents'
      };
    
      sppull(context, options);
    
    }).catch(console.log);
    Mohammed Abbod
    @mhmd2015
    Hi, I have angular SPFx in SP2019 responsible to show MegaMenu's and listing all sites/subsites using this REST API : /_api/web/getsubwebsfilteredforcurrentuser(nwebtemplatefilter=-1,nconfigurationfilter=0), also its working now in [my company].sharepoint.com in cloud, there is one SSO PingFederate controlling the authentication in both environment. is there a library like msal.js be able to talk from one environment to another one using the token that user issued when logged in ? Thanks in advance.
    rs011235
    @rs011235
    Hi, I am facing issue -
    spauth.getAuth is working fine while I am using with http server but it gives error while using with express node server.
    Error is - enrufused to connect 443 port
    jmls
    @jmls

    This works for me:

    const { AuthConfig } = require('node-sp-auth-config');
    const { create } = require('sp-request');
    
    (async () => {
    
      const { siteUrl, authOptions } = await new AuthConfig().getContext();
      const spr = create(authOptions);
    
      const digest = await spr.requestDigest(`${siteUrl}`);
      const res = await spr.post(`${siteUrl}/_api/web/lists/getByTitle('MyList')/items(1)`, {
        headers: {
          'X-RequestDigest': digest,
          'X-HTTP-Method': 'DELETE',
          'IF-MATCH': '*'
        }
      });
    
      console.log(res.statusCode, res.statusMessage);
    
    })().catch(console.warn);

    ok, so I have an issue with this code - and it must be a config setting. If I run this, I get prompted for all my dettails (url, type, username etc)
    however, I get a 401

    if I browse to the site in chrome, and enter the same username, password I get logged on

    what am I missing ? I really would appreciate some help here, my eyes are bleeding from all the googling ;)

    1 reply
    I'm trying to use User credentials (NTLM) btw
    utahisnotastate
    @utahisnotastate
    Hi! Is there an easy way to create a react CEWP that im not seeing? I don't know how to use webpack because i normally use create-react-app . I selected the option to use react but it doesn't look like that did anything?