OData / OData/odataorg.github.io

Odata TripPin sample can not create entity with Gender enum

Open
#361 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
HTML
Stars
73
Forks
106
PR merge metrics
No merged PRs in 30d

Description

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?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the POST against TripPinRESTierService with the Gender values shown, then compare it with the working V4 TripPinServiceRW endpoint. Use the $metadata response to verify the PersonGender definition and determine whether the failure is in the sample service or its documented request format; done means the cause and correct behavior are documented or the sample is corrected.

Written by the indexing model from the issue text.

Assessment

Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.