none
REST API returns two Id fields? RRS feed

  • Question

  • Hi,

    I have a list in my Sharepoint site that has columns as below:

    When I use below REST API, I get two Id fields in the result returned,

    http://mysiteurl/_api/web/lists/getbytitle('reportingexpress')/items

    Part of the result looks like below, as you can see there are two id fields, one is "Id", one is "ID", they have same value (3).

    <content type="application/xml">
        <m:properties>
    	<d:FileSystemObjectType m:type="Edm.Int32">0</d:FileSystemObjectType>
    	<d:Id m:type="Edm.Int32">3</d:Id>
    <d:ContentTypeId>0x0100AB4B9066B7F89541845BF5D48BCCC229</d:ContentTypeId>
    	<d:Title>CRO Townhall</d:Title>
    ...
    	<d:Rank m:type="Edm.Double">1</d:Rank>
    	<d:Category>Firm Risk Committee</d:Category>
    	<d:ID m:type="Edm.Int32">3</d:ID>
    	<d:Modified m:type="Edm.DateTime">2019-02-13T15:51:23Z</d:Modified>
    	<d:Created m:type="Edm.DateTime">2019-02-13T15:51:23Z</d:Created>
    	<d:AuthorId m:type="Edm.Int32">1</d:AuthorId>
    	<d:EditorId m:type="Edm.Int32">1</d:EditorId>			
    <d:OData__UIVersionString>1.0</d:OData__UIVersionString>
    				<d:Attachments m:type="Edm.Boolean">false</d:Attachments>
    				<d:GUID m:type="Edm.Guid">2114e3d2-eaa1-4180-ab73-c618aa423ca8</d:GUID>
    	</m:properties>
    </content>
    

    So my question, why there are two Id fields, and what's the differences, which one should I use? are they always the same?

    Thanks,

    Michael

    Thursday, February 21, 2019 12:14 AM

Answers

  • Hi Michael,

    This is by design, The ID and Id are always show the same value in REST API return. Usually, I use ID to show list item ID.

    Best Regards,

    Dennis


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    • Marked as answer by Michael_bdd Thursday, February 21, 2019 3:51 AM
    Thursday, February 21, 2019 1:53 AM
    Moderator

All replies

  • Hi Michael,

    This is by design, The ID and Id are always show the same value in REST API return. Usually, I use ID to show list item ID.

    Best Regards,

    Dennis


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    • Marked as answer by Michael_bdd Thursday, February 21, 2019 3:51 AM
    Thursday, February 21, 2019 1:53 AM
    Moderator
  • thanks a lot!
    Thursday, February 21, 2019 3:51 AM
  • If this is by design, it is a bad design. Languages and parsers that are case-insensitive all choke on this data. I've encountered this when trying to consume SharePoint data with PowerShell and also when using JSON SerDe parsers. I always have to use a case-insensitive parser to strip out one or the other ID in order to make the content consumable and intuitive in other tools.

    It would be convenient to have an option in the OData query string to disable the unwanted extra ID column.
    Friday, October 18, 2019 11:13 PM