Skip to content
This repository has been archived by the owner on Jan 18, 2021. It is now read-only.

sprLib.user(options).profile() using "post" ? #30

Closed
YakQin opened this issue Jul 16, 2018 · 3 comments
Closed

sprLib.user(options).profile() using "post" ? #30

YakQin opened this issue Jul 16, 2018 · 3 comments
Assignees
Milestone

Comments

@YakQin
Copy link

YakQin commented Jul 16, 2018

Hello,

I run below query but I saw it is a "POST" action and I got error:

"error":{"code":"-2130575251, Microsoft.SharePoint.SPException","message":{"lang":"en-US","value":"The security validation for this page is invalid and might be corrupted. Please use your web browser's Back button to try your operation again."}}}

I tried to add the digest token but it did not work.

I used this API before but I used the "GET" Method and it worked for me.

//////////////////////////////
sprLib.user({
baseUrl: 'https://xxxx.sharepoint.com/teams/StrategyandPOA',
email: 'gui-zhong.qin@xxx.com',
}).profile().then(function (objUser) {
console.log(objUser)
});

capture

@gitbrent
Copy link
Owner

gitbrent commented Jul 18, 2018

Hi @YakQin ,

So, the profile() method attempts to get info from the UserProfile service, and that requires a POST type:

return sprLib.rest({
    url: "_api/SP.UserProfiles.PeopleManager/GetPropertiesFor(accountName=@v)?@v='"+userAcctName+"'",
    type: 'POST',
    metadata: false
});

However, I had not considered the session timeout aspect of doing a POST...

Let me add the ability to pass a digestToken.

@gitbrent gitbrent added this to the 1.8.0 milestone Jul 18, 2018
@gitbrent gitbrent self-assigned this Jul 18, 2018
@YakQin
Copy link
Author

YakQin commented Jul 20, 2018

thanks a lot, but why you preferred "post" while "get" is working
see: https://msdn.microsoft.com/en-us/library/office/dn790354.aspx#bk_PeopleManagerGetPropertiesFor

gitbrent added a commit that referenced this issue Jul 25, 2018
gitbrent added a commit that referenced this issue Jul 25, 2018
@gitbrent
Copy link
Owner

Good catch - I have no idea why a POST was being used for that particular call...??

The userProfile call is now a GET like all the others, so auth shouldn't be an issue anymore.

Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants