OData / odataorg.github.io

Staging site and collaboration repository for http://www.odata.org
MIT License
63 stars 101 forks source link

Odata TripPin sample can not create entity with Gender enum #361

Open dmytro-sylaiev opened 1 year ago

dmytro-sylaiev commented 1 year ago

I'm trying to insert an Entity to the odata sample TripPinRESTierService. Got a special key that allows me to make a modification, send a request

POST https://services.odata.org/TripPinRESTierService/(S(<key>))/People

headers:
Content-Type:application/json

body:
{
"UserName": "teresa",
"FirstName" : "Teresa",
"LastName" : "Gilbert"
}

And have a response 201 Created

But when I add a Gender (enum) value to the body:

POST https://services.odata.org/TripPinRESTierService/(S(<key>))/People

headers:
Content-Type:application/json

body:
{
"UserName": "teresa",
"FirstName" : "Teresa",
"LastName" : "Gilbert",
"Gender" : "Female"
}

I have a 500 Internal Server Error:

{
    "error": {
        "code": "",
        "message": "Gender"
    }
}

The property description in the odata $metadata:

<Property Name="Gender" Type="Trippin.PersonGender" Nullable="false"/>
...
<EnumType Name="PersonGender">
    <Member Name="Male" Value="0" />
    <Member Name="Female" Value="1" />
    <Member Name="Unknown" Value="2" />
</EnumType>

I also tried with setting just int values to the body, or Trippin.PersonGender'Male' but have the same result. The example for the odata.org says I just need to set a simple string value: https://www.odata.org/getting-started/basic-tutorial/#create

It works well when I'm doing same operation for (http://services.odata.org/V4/(S())/TripPinServiceRW) What am I doing wrong?