Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

293
Views
Why is an Enum represented in two different ways in an API request?

I guess that will be a duplicated question because it's something quite basic, but after some search I was not able to find the answer.

I have a .net462 application. I have the following enum:

 public enum Test
 {
     Foo,
     Bar,
 }

and the following endpoint in one controller:

 [HttpGet]
 [Route("myTest")]
 public IEnumerable<Test> GetMyFooTest()
 {
     return new List<Test> { Test.Bar, Test.Foo };
 }

Now, if I use chrome to retrieve data from the endpoint, I get: Browser screenshot

Here the Enums appear in its string form.

However, when I call this endpoint from the front end (JS, jQuery), or if I call it using Postman, I get: Postman screenshot

No matter if I visualise it with JSON, XML or any option: options

Here I get the numerical values of the Enums.

Why this difference? Is there a way to get the string values in the front end? (of course I have the option to change the controller to return a IEnumerable<string> and use a ToString() on the c# side, but that would be quite ugly...).

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!