## Where communities thrive

• Join over 1.5M+ people
• Join over 100K+ communities
• Free without limits
• Create your own community
##### Activity
Obe Lahnkara
=== Error ===
Error: Invalid argument
at Object.decodeType2Message (C:\Users\XXX\Documents\ReactTesting\node-sp-auth-troubleshoot\node_modules\node-ntlm-client\lib\ntlm.js:62:9)
at C:\Users\XXX\Documents\ReactTesting\node-sp-auth-troubleshoot\node_modules\node-sp-auth\lib\src\auth\resolvers\OnpremiseUserCredentials.js:40:35
at async C:\Users\XXX\Documents\ReactTesting\node-sp-auth-troubleshoot\index.js:22:24
Andrew Koltyakov
@koltyakov
What’s the version of Node.js? The latest node-sp-auth update requires at least 10.19.
Are you sure, your environment is NTLM? But not ADFS or something else? Can it be a mixed auth?

can pnp not authenticate on-prem on its own?

Sure thing, no.

Andrew Koltyakov
@koltyakov
Also, what’s the finger print of username/domain? Should be 1) username: john@contoso.com, domain: omitted; 2) username: contoso\john, domain: omitted, 3) username: john, domain: contoso
However, messing up with creds format would end up with incorrect username and password. So it’s something else.
Obe Lahnkara
it should be NTLM, that's what was used on a C# script i saw used to connect to this SP site @koltyakov
and i'm on node 14.4
Obe Lahnkara
ok i got it
did some debugging w troubleshooter and established a connection
now what? do i just copy the private.uat into my credential Options
?
Andrew Koltyakov
@koltyakov
What was the issue?
Obe Lahnkara
incorrect formatting of sharepoint url
i'm loading the urls from an external list in a module and noticed i typed them as http instead of https
edited that in credentialOptions and now i can query the digest perfectly
Andrew Koltyakov
@koltyakov
Cool, happy coding!
Obe Lahnkara
and to you!
Obe Lahnkara
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
@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), {
'X-RequestDigest': digest,
'X-HTTP-Method': 'DELETE',
'IF-MATCH': '*'
}
});

console.log(res.statusCode, res.statusMessage);

})().catch(console.warn);
Obe Lahnkara
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
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
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
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
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?
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
I am looking to authenticate with a smart card. I was wondering if that is possible?
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,
credentials: "include",
Accept: "application/json; odata=verbose",
"Content-Type": "application/json; odata=verbose"
}
};

//Get RequestDigest First
.then(r=>
{