Modeling using the Meta API
With the Meta API, you can create and view Integration Objects.
The IntegrationService API exposes all configured Integration Objects through the Integration API. The integrationservice extension comes with one integration object, IntegrationService.
When you define a new Integration Object, the Integration API module exposes it through the following URL. Because IntegrationService is also an Integration Object, you can request $metadata and a service document.
https://localhost:9002/odata2webservices/IntegrationService/IntegrationObjects
The $metadata query option retrieves all metadata for an Integration Object. For example:
GET https://localhost:9002/odata2webservices/IntegrationService/$metadata
https://localhost:9002/odata2webservices/IntegrationService/IntegrationObjectItemsAll Integration Object Item attributes are exposed through:
https://localhost:9002/odata2webservices/IntegrationService/IntegrationObjectItemAttributes
IntegrationService Meta API Examples
The following examples show how to make POST and GET requests to the IntegrationService API.
POST to the IntegrationService API Example
This POST request example shows how to create an Integration Object named ExampleProduct through the IntegrationService Meta API. The example uses a simplified payload for circular reference attributes. For more information, see Circular Reference Attributes.
Request URL
POST https://localhost:9002/odata2webservices/IntegrationService/IntegrationObjects
Request Body
{
"code": "ExampleProduct",
"integrationType": {
"code": "INBOUND"
},
"items": [
{
"code": "Catalog",
"type": { "code": "Catalog" },
"integrationObject": { "code": "ExampleProduct" },
"attributes": [
{
"attributeName": "id",
"attributeDescriptor": {
"qualifier": "id",
"enclosingType": { "code": "Catalog" }
}
},
{
"attributeName": "name",
"attributeDescriptor": {
"qualifier": "name",
"enclosingType": { "code": "Catalog" }
}
}
]
},
{
"code": "CatalogVersion",
"type": { "code": "CatalogVersion" },
"integrationObject": { "code": "ExampleProduct" },
"attributes": [
{
"attributeName": "version",
"attributeDescriptor": {
"qualifier": "version",
"enclosingType": { "code": "CatalogVersion" }
}
},
{
"attributeName": "catalog",
"attributeDescriptor": {
"qualifier": "catalog",
"enclosingType": { "code": "CatalogVersion" }
},
"returnIntegrationObjectItem": {
"code": "Catalog",
"integrationObject": { "code": "ExampleProduct" }
},
"unique": true
}
]
},
{
"code": "Unit",
"type": { "code": "Unit" },
"integrationObject": { "code": "ExampleProduct" },
"attributes": [
{
"attributeName": "code",
"attributeDescriptor": {
"qualifier": "code",
"enclosingType": { "code": "Unit" }
}
},
{
"attributeName": "unitType",
"attributeDescriptor": {
"qualifier": "unitType",
"enclosingType": { "code": "Unit" }
}
}
]
},
{
"code": "Product",
"type": { "code": "Product" },
"integrationObject": { "code": "ExampleProduct" },
"root": true,
"attributes": [
{
"attributeName": "code",
"attributeDescriptor": {
"qualifier": "code",
"enclosingType": { "code": "Product" }
}
},
{
"attributeName": "catalogVersion",
"attributeDescriptor": {
"qualifier": "catalogVersion",
"enclosingType": { "code": "Product" }
},
"returnIntegrationObjectItem": {
"code": "CatalogVersion",
"integrationObject": { "code": "ExampleProduct"}
}
},
{
"attributeName": "name",
"attributeDescriptor": {
"qualifier": "name",
"enclosingType": { "code": "Product" }
}
},
{
"attributeName": "description",
"attributeDescriptor": {
"qualifier": "description",
"enclosingType": { "code": "Product" }
}
},
{
"attributeName": "unit",
"attributeDescriptor": {
"qualifier": "unit",
"enclosingType": { "code": "Product" }
},
"returnIntegrationObjectItem": {
"code": "Unit",
"integrationObject": { "code": "ExampleProduct"}
}
},
{
"attributeName": "order",
"attributeDescriptor": {
"qualifier": "order",
"enclosingType": { "code": "Product" }
}
}
]
}
]
}
GET from the IntegrationService API
This GET request example shows how to view the ExampleProduct Integration Object posted in the previous example, using the IntegrationService Meta API.
Request URL
GET https://localhost:9002/odata2webservices/IntegrationService/IntegrationObjects?$filter=code eq 'ExampleProduct'
Response Body
{
"d": {
"results": [
{
"__metadata": {
"id": "https://localhost:9002/odata2webservices/IntegrationService/IntegrationObjects('ExampleProduct')",
"uri": "https://localhost:9002/odata2webservices/IntegrationService/IntegrationObjects('ExampleProduct')",
"type": "HybrisCommerceOData.IntegrationObject"
},
"code": "ExampleProduct",
"integrationKey": "ExampleProduct",
"integrationType": {
"__deferred": {
"uri": "https://localhost:9002/odata2webservices/IntegrationService/IntegrationObjects('ExampleProduct')/integrationType"
}
},
"items": {
"__deferred": {
"uri": "https://localhost:9002/odata2webservices/IntegrationService/IntegrationObjects('ExampleProduct')/items"
}
}
}
]
}
}