0

Say, for such an entity defined below, what is the correct response for GET "serviceRoot/entity(1)/nav"? Assuming entity with id 1 has valid values, but its stored key for the 'nav' reference is null.

<EntityType Name="entityType">
    <Key>
        <PropertyRef Name="id"/>
    </Key>
    <Property Name="id" Nullable="false" Type="Edm.Integer"/>
    <Property Name="name" Nullable="false" Type="Edm.String"/>
    <NavigationProperty Name="nav" Nullable="true" Type="this.navType"/>
</EntityType>

<EntityType Name="navType">
    <Key>
        <PropertyRef Name="navId"/>
    </Key>
    <Property Name="navId" Nullable="false" Type="Edm.Integer"/>
    <Property Name="name" Nullable="false" Type="Edm.String"/>
</EntityType>

<EntityContainer Name="Container">
    <EntitySet EntityType="navType" Name="navSet"/>
    <EntitySet EntityType="entityType" Name="entity">
        <NavigationPropertyBinding Path="nav" Target="this.navSet"/>
    </EntitySet>
</EntityContainer>
Jia Fang
  • 47
  • 6
  • Returning status 204 seems to work on Excel. But I still need more legit explanations. I cannot find good example to solidify my guess. – Jia Fang Nov 19 '20 at 02:38

1 Answers1

0

204 No Content is the correct response according to the OData v4 specification.

If the relationship terminates on a single entity, the response MUST be the format-specific representation of the related single entity. If no entity is related, the service returns 204 No Content.

Source: Requesting Related Entities

Good guess!

Norm Cota
  • 26
  • 2