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 :
Small and medium business | Business Central, N...
Unanswered

retrieving OkHttp json response data

(0) ShareShare
ReportReport
Posted on by 90

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.

Screenshot-_2800_123_2900_.png

Screenshot-_2800_124_2900_.png

I have the same question (0)
  • gert-jan.terschure Profile Picture
    200 on at

    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" }
        }
    ]
            
        

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 > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 3,226

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 2,047 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,257 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans