Import SAP OData metadata as an API

APPLIES TO: All API Management tiers

This article shows how to import an OData service using its metadata description. In this article, SAP Gateway Foundation serves as an example.

In this article, you'll:

  • Retrieve OData metadata from your SAP service
  • Import OData metadata to API Management, either directly or after conversion to an OpenAPI specification
  • Complete API configuration
  • Test the API in the Azure portal

Note

Importing an OData API to API Management from its metadata description is in preview. Learn more.

Prerequisites

  • An existing API Management instance. Create one if you haven't already.

  • An SAP system and service exposed as OData v2 or v4.

  • If your SAP backend uses a self-signed certificate (for test purposes), you may need to disable the verification of the trust chain for SSL. To do so, configure a backend in your API Management instance:

    1. In the Azure portal, under APIs, select Backends > + Add.
    2. Add a Custom URL pointing to the SAP backend service.
    3. Uncheck Validate certificate chain and Validate certificate name.

    Note

    For production scenarios, use proper certificates for end-to-end SSL verification.

Retrieve OData metadata from your SAP service

Retrieve metadata XML from your SAP service, using one of the following methods. If you plan to convert the metadata XML to an OpenAPI specification, save the file locally.

  • Use the SAP Gateway Client (transaction /IWFND/GW_CLIENT), or
  • Make a direct HTTP call to retrieve the XML: http://<OData server URL>:<port>/<path>/$metadata

Go to your API Management instance

  1. In the Azure portal, search for and select API Management services.

    Select API Management services

  2. On the API Management services page, select your API Management instance.

    Select your API Management instance

Import API to API Management

Choose one of the following methods to import your API to API Management: import the metadata XML as an OData API directly, or convert the metadata XML to an OpenAPI specification.

Import OData metadata

  1. In the left menu, select APIs > + Add API.

  2. Under Create from definition, select OData.

    Screenshot of creating an API from an OData description in the portal.

  3. Enter API settings. You can update your settings later by going to the Settings tab of the API.

    1. In OData specification, enter a URL for an OData metadata endpoint, typically the URL to the service root, appended with /$metadata. Alternatively, select a local OData XML file to import.

    2. Enter remaining settings to configure your API. These settings are explained in the Import and publish your first API tutorial.

  4. Select Create.

    The API is added to the APIs list. The entity sets and functions that are exposed in the OData metadata description appear on the API's Entity sets and functions tab.

    Screenshot of OData entity sets and functions in the portal.

Update the OData schema

You can access an editor in the portal to view your API's OData schema. If the API changes, you can also update the schema in API Management from a file or an OData service endpoint.

  1. In the portal, navigate to your API Management instance.

  2. In the left menu, select APIs > your OData API.

  3. On the Entity sets and functions tab, select the context menu (...) next to an entity set or function, and select Edit.

    Screenshot of context menu for an OData entity set in the portal.

  4. Review the schema. If you want to update it, select Update from file or Update schema from endpoint.

    Screenshot of schema editor for OData API in the portal.

Test your OData API

  1. In the left menu, select APIs > your OData API.

  2. On the Entity sets and functions tab, select the context menu (...) next to an entity set or function, and select Test.

    Screenshot of Test option on context menu for an OData entity set in the portal.

  3. In the test console, enter template parameters, query parameters, and headers for your test, and select Test. Learn more about testing an API in the portal.

Secure your OData API

Secure your OData API by applying both existing authentication and authorization policies and an OData validation policy to protect against attacks through OData API requests.

Tip

In the portal, configure policies for your OData API on the API policies tab.

Production considerations