
am using web service which is created in the Business central, I tried to get all json data using ODataV4 URL using OkHttp GET methos and successfulIy got OkHttp response, But when I tried to get jason element from from response in java code it is giving exception as JSONObject["Code"] not found even thought that key is present in response obtained from GET method. Could anyone provide a way so I can successfully retrieve all key value pairs of JASON data.
What is the object you're trying to deserialize, please provide a small sample? If you're pulling an entity collection instead of a single entity, the result returned will look similar to below. This means that a property such as "Code" is not at the root element, but in root -> value -> object -> code. My advise is to use the Gson library to deserialize the returned Json object, so you can work with it as if it's a regular Java object.
{
@odata.annotations: "This are the @odata. fields, like @odata.count",
value: [
{ "Object 1" },
{ "Object 2" },
{ "Object n" }
}
]