I've been fighting to get user data using the REST API but I can't get it to work mainly because I am getting a server error 500

```
"Network Error: 500 Internet Server Error - http://mysite/_api/SP.UserProfiles.PeopleManager/GetMyProperties

```

I'm not sure what I've done wrong but I can't get over this error at all. Does anyone know what could be the cause of this or how I can fix this. Here is my REST code as well 

```
//Connection and Data
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) {
        success(data.d);
    },
    error: error
});
}

// Usage   
getMyUserProfile(
           function (properties) {
          document.getElementById("sp-name").innerHTML = (properties.DisplayName),
          document.getElementById("sp-avatar").innerHTML = (properties.PictureUrl);
      },
      function (data) {
          console.log(JSON.stringify(data));
      });

```