Search code examples
javaandroidodatadynamics-crmolingo

Parse Odata Values returned by Microsoft CRM Web API


I'm building an android application that communicates with Microsoft Dynamics CRM. Currently, I'm accessing the Web APIs using an Access Token Generated.

Calling the Web APIs I'm able to get the Odata JSON into a response string.

{
 "@odata.context": "[OrganizationURI]/api/data/v8.2/$metadata#accounts(name)",
 "value": [
  {
   "@odata.etag": "W/\"501097\"",
   "name": "Fourth Coffee (sample)",
   "accountid": "89390c24-9c72-e511-80d4-00155d2a68d1"
  },
  {
   "@odata.etag": "W/\"501098\"",
   "name": "Litware, Inc. (sample)",
   "accountid": "8b390c24-9c72-e511-80d4-00155d2a68d1"
  },
  {
   "@odata.etag": "W/\"501099\"",
   "name": "Adventure Works (sample)",
   "accountid": "8d390c24-9c72-e511-80d4-00155d2a68d1"
  }
  ]
 }

I'd like to parse the String and get the values of Name.

I've tried to convert the String to a JSON Object, and then try to get the name from it but it returns me a null value.


Solution

  • I figured it out, I was referring to the wrong position. Using a JSON Visualizer such as JSONmate helped figure out which position to refer to.