Quantcast
Channel: Question and Answer » json
Viewing all articles
Browse latest Browse all 148

How can I get user information from user ID?

$
0
0

I am writing a very small C# console app and I am making an HttpWebRequest to get the list items in a task log and send a daily summary email to everyone with something ‘assigned to’ them, showing what is past due, due today, and coming due within two days.

Everything is being returned fine, but I need to get a user’s email based on their ID.

Sample JSON returned (sanitized a bit):

  {
    "__metadata": {
      "id": "Web/Lists(guid'3e4fa151-ee48-46f9-8283-2c0e80145ab8')/Items(8)",
      "uri": "https://<server>/<custom site>/_api/Web/Lists(guid'GUIDHERE')/Items(8)",
      "etag": ""12"",
      "type": "SP.Data.Task_x0020_LogListItem"
    },
    "AssignedTo": {
      "results": [
        {
          "__metadata": {
            "id": "472ce0fc-6066-4bd9-9784-9d3f0fc2a264",
            "type": "SP.Data.UserInfoItem"
          },
          "FirstName": "First Name",
          "LastName": "Last Name"
        }
      ]
    },
    "Title": "Task Tile Here",
    "AssignedToId": {
      "__metadata": {
        "type": "Collection(Edm.Int32)"
      },
      "results": [
        7403
      ]
    },
    "DueDate": "2015-09-30T04:00:00Z",
    "Priority": "3"
  }

Specifically this part:

"AssignedToId": {
          "__metadata": {
            "type": "Collection(Edm.Int32)"
          },
          "results": [
            7403
          ]
        }

How can I look up profile information for user 7403?

I’ve tried the User Profile Web Service but nothing (to my current knowledge) allows a lookup by ID, it’s find user profile by username, or email, etc.

Basically I just need to get the email address for the user the task is assigned to.

Also, as a bonus question, I can’t seem to access FirstName and LastName in AssignedTo. I am using JSON.Net and I have deserialized the entire object that is returned, but should I be doing something differently with this “nested” JSON?


Viewing all articles
Browse latest Browse all 148

Trending Articles