1

I am trying to follow the guidance in many articles, one by Fabian williams, on how to make queries from Fiddler or Postman, but I keep getting 401 unauthorized. I have SharePoint on prem 2016, with Feature pack 2.

I am trying to make a post request, to a url that looks like this:

http://devserver/sites/hr/_api/contextinfo

in Postman, I added the authorization as basic auth, with my username and password, which added the Authorization header for me, and Accept: application/json;odata=verbose;

When I try to make the request, I get 401 unauthorized.

Here's how my request looks like in Postman:

enter image description here

Any help is appreciated.

Thanks.

Zdeněk Vinduška
  • 2,889
  • 2
  • 12
  • 24
Brittany Rutherford
  • 878
  • 2
  • 16
  • 35
  • Use NTLM as your auth mechanism. –  Feb 23 '19 at 16:47
  • I tried to do that, didn't work. – Brittany Rutherford Feb 23 '19 at 17:23
  • @TrevorSeward do I need to be signed in with the same user I have access to in SharePoint? For example, I am signed to my computer with a local user, but connecting to sharepoint with a domain user. – Brittany Rutherford Feb 24 '19 at 00:23
  • With Postman, you can pass arbitrary credentials. But you should make sure your username is just the sAMAccountName and the Domain box is filled with your domain's FQDN (e.g. corp.example.com). –  Feb 25 '19 at 16:08
  • @TrevorSeward I tried that, it doesn't work. I saw some examples requiring me to do a POST request to the contextapi end point in order to generate access token, but that request itself isn't authorized. What am I missing? – Brittany Rutherford Feb 26 '19 at 07:55

2 Answers2

0

Dont forget to use BearerToken from authentication request to the Data request.

By authentication to the login.microsoftonline.com/company.onmicrosoft.com/oauth2/token URL address, you will get a bearer token (you need to fill body with user_credentials). This bearer token will be used in the data request.

Hope it helps!

Gryu
  • 291
  • 2
  • 13
Zdeněk Vinduška
  • 2,889
  • 2
  • 12
  • 24
0

Within Fiddler is an option to "Automatically Authenticate" and it works beautifully.

You'll still have to call the contextinfo and copy and paste the digest into your call using the X-RequestDigest header

enter image description here

Mike
  • 12,186
  • 8
  • 41
  • 64