Skip to content

Latest commit

 

History

History
158 lines (101 loc) · 9.04 KB

File metadata and controls

158 lines (101 loc) · 9.04 KB
title Import SAP OData Metadata as an API
titleSuffix
description Learn how to import OData metadata from SAP as an API to Azure API Management, either directly or by converting the metadata to an OpenAPI specification.
ms.service azure-api-management
ms.custom
build-2024
author martinpankraz
ms.author mapankra
ms.topic how-to
ms.date 03/16/2026

Import SAP OData metadata as an API

[!INCLUDE api-management-availability-all-tiers]

This article describes how to import an OData (Open Data Protocol) service into Azure API Management by using OData metadata. The following example uses SAP Gateway Foundation.

In this article, you learn how to:

[!div class="checklist"]

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

Prerequisites

  • Create an API Management instance.

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

  • If your SAP backend uses a self-signed certificate (for testing), you might 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 > + Create new backend.
    2. Add a Custom URL that points to the SAP backend service.
    3. Expand the Advanced section, then clear the Validate certificate chain and Validate certificate name checkboxes.

    [!NOTE] In production scenarios, use proper certificates for end-to-end SSL verification.

Retrieve OData metadata from your SAP service

Use one of the following methods to retrieve metadata XML from your SAP service. 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).
  • Make a direct HTTP call to retrieve the XML: http://<OData server URL>:<port>/<path>/$metadata.

[!INCLUDE api-management-navigate-to-instance]

Import an 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.
  • Convert the metadata XML to an OpenAPI specification.

[!INCLUDE api-management-import-odata-metadata]

Convert OData metadata to OpenAPI JSON

  1. Use an OASIS open-source tool for OData v2 or OData v4, depending on your metadata XML.

    The following example converts OData v2 XML for the test service epm_ref_apps_prod_man_srv:

    odata-openapi -p --basePath '/sap/opu/odata/sap/epm_ref_apps_prod_man_srv' \
     --scheme https --host <your IP address>:<your SSL port> \
     ./epm_ref_apps_prod_man_srv.xml

    [!NOTE]

    • For testing with a single XML file, you can use a web-based converter that's based on an open-source tool.
    • With the tool or the web-based converter, specifying the <IP address>:<port> of your SAP OData server is optional. Alternatively, add this information later in your generated OpenAPI specification or after you import the file to API Management.
  2. Save the openapi-spec.json file locally for import to API Management.

Import OpenAPI specification

  1. In the sidebar menu, in the APIs section, select APIs.

  2. Under Create from definition, select the OpenAPI tile:

    :::image type="content" source="./media/import-api-from-oas/oas-api.png" alt-text="Screenshot that shows the OpenAPI tile.":::

  3. Choose Select a file, and then select the openapi-spec.json file that you saved locally in a previous step.

  4. Enter API settings. You can set these values when you import the API or configure them later by going to the Settings tab.

    • For the API URL suffix, we recommend using the same URL path as that of the original SAP service.

    • For more information about API settings, see Import and publish your first API tutorial.

  5. Select Create.

Note

For information about API import limitations, see API import restrictions and known issues.

Complete the API configuration

Add the following three operations to the API that you imported. To learn how, see Add and test an operation.

  • GET /$metadata

    Operation Description Additional configuration for the operation
    GET /$metadata Enables API Management to reach the $metadata endpoint, which is required for client integration with the OData server.

    This required operation isn't included in the OpenAPI specification that you generated and imported.
    Add a 200 OK response.

    :::image type="content" source="media/sap-api/get-metadata-operation.png" alt-text="Screenshot that shows the GET metadata operation.":::

  • HEAD /

    Operation Description
    HEAD / Enables the client to exchange cross-site request forgery (CSRF) tokens with the SAP server when required.

    SAP also allows CSRF token exchange via the GET verb.

    CSRF token exchange isn’t covered in this article. See an example API Management policy snippet to broker token exchange.

    :::image type="content" source="media/sap-api/head-root-operation.png" alt-text="Screenshot that shows the operation for fetching tokens.":::

  • GET /

    Operation Description Additional configuration for the operation
    GET / Enables policy configuration at the service root. Configure the following inbound rewrite-uri policy to append a trailing slash to requests that are forwarded to the service root:

    <rewrite-uri template="/" copy-unmatched-params="true" />

    This policy removes potential ambiguity among requests with and without trailing slashes. These two types of requests are treated differently by some backends.

    :::image type="content" source="media/sap-api/get-root-operation.png" alt-text="Screenshot that shows the GET operation for the service root.":::

You also need to configure authentication to your backend by using an appropriate method for your environment. For examples, see Authentication and authorization.

Test your API

  1. Navigate to your API Management instance.

  2. In the sidebar menu, select APIs > APIs.

  3. Under All APIs, select your imported API.

  4. Select the Test tab to access the test console.

  5. Select an operation, enter any required values, and then select Send.

    For example, test the GET /$metadata call to verify connectivity to the SAP backend.

  6. View the response. To troubleshoot, trace the call.

  7. When you're done testing, exit the test console.


Production considerations

[!INCLUDE api-management-define-api-topics.md]