Domanda

I need get multiple users by ID with REST API. I looked this question: How to get multiple users with REST API

But is not answered.

I've the ID's in an array:

var people = [426, 352, 155];

I've already seen this way:

http://siteurl/_vti_bin/ListData.svc/UserInformationList(426)

But I want get all users info in only one request.

È stato utile?

Soluzione

For few items in ID's array, then you can try following

/_api/Web/Lists/GetByTitle('User Information List')/Items?$filter=(Id eq 426) or (Id eq 352) or (Id eq 155)

It will give you all users in one request. Remember GET request has MAX URL length.

For many items in ID's array, you have to use CAML & POST. CAML Should look like

<Where>
    <In>
        <FieldRef Name="ID" />
        <Values>
            <Value Type="Integer">426</Value>
            <Value Type="Integer">352</Value>
            <Value Type="Integer">155</Value>
            .............
        </Values>
    </In>
</Where>

End-Point will be

/_api/Web/Lists/GetByTitle('User Information List')/getitems

Also see my another answer about MAX URL length for GET request.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a sharepoint.stackexchange
scroll top