1

Error while getting data from http://...-my.sharepoint.com

XMLHttpRequest cannot load https://aaaa-my.sharepoint.com/_api/SP.UserProfiles.PeopleManager/GetMyProperties. Response to preflight request doesn't pass access control check: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. Origin 'https://aaaa.sharepoint.com' is therefore not allowed access. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.

Please help me how to fix them. Thanks

LokiAlice
  • 53
  • 6

2 Answers2

0

You are getting CORS(Cross-origin resource sharing) error here.

The resources you are requesting is not allowing your domain to access the requested resources.

Have you enabled CORS headers on SharePoint?

Here are link to few answers on SO that might help,
enable-cors-in-sharepoint-2013
401-response-for-cors-request-in-iis-with-windows-auth-enabled

Community
  • 1
  • 1
Gaurav Gandhi
  • 2,536
  • 2
  • 23
  • 35
0

The error is because you are trying to make Cross Domain call from aaa.sharepoint.com to aaa-my.sharepoint.com.

I see you are trying to fetch user profile properties of logged in user. For that you do not need to have My Site Base Url. The REST api call would also work with the current site collection base url. So http://aaa.sharepoint.com/_api/SP.UserProfiles.PeopleManager/GetMyProperties should fetch you your desired result

Vineet Desai
  • 430
  • 2
  • 8