web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Convert Web API Json response to Entity Collection

(0) ShareShare
ReportReport
Posted on by 483
HttpResponseMessage response = httpClient.GetAsync(ConfigurationManager.AppSettings["ServerAddress"] + "api/data/v8.0/" + uri, HttpCompletionOption.ResponseHeadersRead).Result;
            JObject responseObject = new JObject();
            if (response.IsSuccessStatusCode)
            {
                responseObject = JObject.Parse(response.Content.ReadAsStringAsync().Result);

 dynamic systemUserObject = JsonConvert.DeserializeObject(jRetrieveResponse.ToString());

                foreach (var data in systemUserObject.value)
                {
               var contactType= data.contacttype.Value;
                }
         
            }

Iam using Rest API to connect CRM and while converting Can we convert Json object to entity Collection ? or is there any easy way to convert response data to entity collection ? 

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Rawish Kumar Profile Picture
    13,758 on at

    Hi Krishna,

    It is Do-able : www.newtonsoft.com/.../ToObjectComplex.htm

  • CRM Develope Profile Picture
    894 on at

    krishna prasad

    Have a look Here.

    https://yanivrdt.wordpress.com/2015/09/27/crm-web-api-preview-generate-strongly-typed-objects-from-metadata-document/

    if (retrieveResponse.IsSuccessStatusCode)

                   {

                       var Content = await retrieveResponse.Content.ReadAsStringAsync();

                       ODataResponse<T>  odataresponse = JsonConvert.DeserializeObject<ODataResponse<T>>(Content);

                   }

    public class ODataResponse<T>

    {

           public T[] Value { get; set; }

      }

    Kind regards,

    CRM Developer

  • dkrishna Profile Picture
    483 on at

    here how can i check condition whether field present in json object before assigning value to property ? is there any other alternative which converts  response to entity collection when we use SOAP IOrganization Service ?

  • dkrishna Profile Picture
    483 on at

    Here main problem is assining values to properties and need to check field existance before assining value to property like below ? Any Ideas?

      foreach (var data in systemUserObject.value)

                   {

                  var contactType= data.contacttype.Value;

                   }

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans