Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get OData $metadata in JSON format

Tags:

is it possible to get metadata of an OData service in JSON format?

When I try to use format=json , it doesn't work. Here is what I tried:

http://odata.informea.org/services/odata.svc/$metadata/?format=json 
like image 251
Omar Avatar asked Sep 08 '13 11:09

Omar


People also ask

Can we query or retrieve metadata in JSON format?

Metadata may be retrieved in JSON format using our REST API, or in XML format as documented below. Most DOI-to-metadata queries are done via HTTPS using synchronous HTTPS queries, but may also be submitted as asynchronous batch queries.

What is $metadata in OData?

The OData $metadata file is a CSDL file that is made available to clients to help them discover the structure and organization of the entities, navigations, and the service operations that are available to manage resources beyond the usual create, retrieve, update, or delete operations.

Does OData use JSON?

The OData spec also has a query parameter, $format, that accepts json as one of its values. Although using this format parameter to request JSON is part of the OData specification, not every data service knows how to process the parameter. In fact, when you create a . NET WCF Data Service, it returns ATOM by default.


1 Answers

The $metadata document is in the CSDL format, which currently only has an XML representation. (As a side note, if you do want to request the json format for a different kind of OData payload, make sure the format query token has a $ in front of it: $format=json.)

So, no it is not possible. You can, however, get the service document in JSON, which is a subset of the $metadata document:

http://odata.informea.org/services/odata.svc?$format=json 

This won't have type information, but it will list the available entry points of the service (i.e., the entity sets).

like image 195
Jen S Avatar answered Oct 22 '22 22:10

Jen S