Metadata
Metadata
The OData API supports metadata queries to retrieve information about the data you have surfaced in your account. The sections below outline how to issue these metadata queries and what they return.
Table Listing
Issue a GET query to the OData Service URL with the relevant workspace name (https://cloud.cdata.com/api/odata/{workspace_name}
) to retrieve a JSON-formatted listing of the tables you have made available in your OData API. For example:
GET https://cloud.cdata.com/api/odata/{workspace_name}/
The results of this query will be formatted similarly to this example, though the contents will vary depending on your data sources:
{
"@odata.context": "https://cloud.cdata.com/api/odata/{workspace_name}/$metadata",
"value": [
{
"name": "Accounts",
"kind": "EntitySet",
"url": "Accounts"
},
{
"name": "Customers",
"kind": "EntitySet",
"url": "Customers"
}
{
"name": "Inventory",
"kind": "EntitySet",
"url": "Inventory"
},
]
}
Each of the items in this result (Accounts, Customers, and Inventory) is a table that has been added to the OData API.
Detailed Metadata Information
To retrieve an XML-formatted list of column data types, resource keys, and other information for all of your OData tables, issue a GET query to the OData Service URL and append $metadata. For example:
GET https://cloud.cdata.com/api/odata/{workspace_name}/$metadata
Below is a truncated example snippet from the results of this query:
<?xml version="1.0" encoding="utf-8"?>
<edmx:Edmx Version="4.0" xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx">
<edmx:DataServices>
<Schema Namespace="CData" xmlns="http://docs.oasis-open.org/odata/ns/edm">
<EntityType Name="Customers">
<Key>
<PropertyRef Name="Id" />
</Key>
<Property Name="Id" Type="Edm.Int32" Nullable="false" />
<Property Name="Company" Type="Edm.String" Nullable="true" MaxLength="2000" />
<Property Name="FirstName" Type="Edm.String" Nullable="true" MaxLength="2000" />
<Property Name="LastName" Type="Edm.String" Nullable="true" MaxLength="2000" />
<Property Name="Email" Type="Edm.String" Nullable="true" MaxLength="2000" />
</EntityType>
[...]
<EntityContainer Name="CData">
<EntitySet Name="Customers" EntityType="CData.Customers" />
[...]
</EntityContainer>
</Schema>
</edmx:DataServices>
</edmx:Edmx>
In these results:
- Each table is grouped into a separate EntityType, with each column designated by a Property.
- The Key attribute indicates which property (column) is the table’s primary key.
- The full list of entities is stored in EntityContainer at the end of the results.
Note: When Salesforce makes a request to the OData Service URL, any EntityType that does not currently contain a Key element returns a <Key>...</Key>
section that contains references to every property (column) in the entity. For example, a truncated $metadata response for Salesforce looks like the following:
<EntityType Name="Dbo_Account">
<Key>
<PropertyRef Name="Id" />
<PropertyRef Name="CreatedById" />
...
</Key>
<Property Name="Id" Type="Edm.String" Nullable="false" MaxLength="18"/>
<Property Name="CreatedById" Type="Edm.String" Nullable="true" MaxLength="18"/>
...
</EntityType>
The Key attribute contains all the columns of the table, so that every column can be treated as a key.