0

Can I access mobile number from AD in an Office 365 project using rest api or server side code?

Currently I am able to get information like emailand name from rest api but not mobile number or phone number.

  • Is the value available in customers Azure AD? – Robert Lindgren Jul 1 '15 at 6:39
  • Not Azure it is SharePoint Online office365 site. – Harsh Bhavsar Jul 1 '15 at 6:49
  • Well, in Office 365 the user data is saved in Azure AD... hence the question – Robert Lindgren Jul 1 '15 at 6:57
  • i am not able to login.says " No subscriptions found." – Harsh Bhavsar Jul 1 '15 at 7:19
1

I got the solution with the help of this link
here is the complete method

function getInformation(userEmailId) {
    var url = _spPageContextInfo.siteAbsoluteUrl + "/_api/SP.UserProfiles.PeopleManager/GetPropertiesFor(accountName=@v)?@v='i:0%23.f|membership|" + userEmailId + "'";
    $.ajax({
        url: url,
        method: "GET",
        async: false,
        headers: { "Accept": "application/json; odata=verbose" },

        contentType: "application/json",
        dataType: "json",

        success: function (data) {
            var obj = data.d.UserProfileProperties;
          if(typeof(obj)  != "undefined") {

            obj =  obj.results
            $.each(obj, function (key, value) {
                if (obj[key].Key == "WorkPhone") {
                    alert(obj[key].Value);
                }
            });
          }
          else{
            alert('Wrong User');
          }
        },
        error: function (data) {
        }
    });
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.