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

  • gert-jan.terschure Profile Picture
    200 on at
    RE: retrieving OkHttp json response 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" }
        }
    ]
            
        

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
YUN ZHU Profile Picture

YUN ZHU 606 Super User 2025 Season 1

#2
Mansi Soni Profile Picture

Mansi Soni 463

#3
Sagar Dangar, MCP Profile Picture

Sagar Dangar, MCP 391

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans