SharePoint Client Side REST API 500 Internal Server Error

Hi There,

I have been now in code again since last two months and facing the developer life challenges :P .

I am calling the GetMyProperties from client side REST API method "/_api/SP.UserProfiles.PeopleManager/GetMyProperties" but my site is throwing 500 internal server error or 400 bad request. Life time annoying errors :-/ . My code was working fine on my dev machine but not on client's server, so apparently its a server configuration issue.

Things to check when you get 500 Internal Server Error or similar IIS erros on "/_api/XXXXXXXXXXXXXXXX" or same kind of issues is, 

1. Check your User Profile Service is running properly
2. Check your my site is configured properly
3. Check your my site is configured in my site host application in User Profile Service

In my case, the issue was, my MySite was not configured in User Profile Service and when i open MySite it throws error and a correlation ID. So i added my MySite in User Profile Service and also enabled Self-Service Site Creation on my MySite. After that my MySite appeared fine and so my code also worked fine and returned me the required data.


[code] //Display User profile properties on top header function getMyUserProfile(success, error) { var siteUrl = _spPageContextInfo.siteAbsoluteUrl; $.ajax({ url: siteUrl + "/_api/SP.UserProfiles.PeopleManager/GetMyProperties", method: "GET", headers: { "Accept": "application/json; odata=verbose" }, success: function (data) { var json = $.parseJSON(JSON.stringify(data.d)); alert(json.DisplayName); }, error: error }); } [/code]


    

Comments

Popular Posts

GREYCstoration Oil Paint plugin for Photoshop

Service Bus Gateway service stuck at Starting

PowerApps SubmitForm not clearing People Picker value

Apple iPhone sending SMS automatically 00447786205094

Download file failed signature verification and may have been tampered with - Workflow Manger 1.0 Refresh (CU2)