Skip to main content

Notifications

Service | Customer Service, Contact Center, Fie...
Answered

How to get picklist values in console application

Posted on by 10

I want "Male" or "Female" instead of 1 or 2 in my response can any one help me with this.

Below is my code,

var response = client.GetAsync("contacts?$select=firstname,gendercode&$top=2").Result;

if (response.IsSuccessStatusCode)
{

     JObject body = JObject.Parse(response.Content.ReadAsStringAsync().Result); 
     Console.WriteLine("{0}", body);
}

else
{
     Console.WriteLine("Error : " + response.ReasonPhrase);
}

  • Verified answer
    a33ik Profile Picture
    a33ik 84,321 Most Valuable Professional on at
    RE: How to get picklist values in console application

    Hello,

    The easiest way is to include an additional header to your request. Check more information here - bengribaudo.com/.../dataverse-web-api-tip-formatted-values

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to get picklist values in console application

    Hi partner,

    The picklist values you mentioned are values of optionset field?

    The optionset field have value and label, what you need is label not value.

    pastedimage1625128645630v1.png

    Maybe you can refer following link to get optionset field label:

    Retrieve table definitions by name or MetadataId (Microsoft Dataverse) - Power Apps | Microsoft Docs

    Regards,

    Leah Ju

    Please mark as verified if the answer is helpful. Welcome to join hot discussions in Dynamics 365 Forums.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Complete!

🔔 Be sure to subscribe to the new forums you are interested in to stay up to date! 🔔

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,902 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 229,336 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans