Building OpenAPI request
Tags: api, tutorial, webmethods, integration
Published: 2022-11-22 13:37:49

---
title: Building OpenAPI request
published: true
date: 2022-10-11 14:20:10 UTC
tags: api, tutorial, webmethods, integration
canonical_url: https://tech.forums.softwareag.com/t/building-open-api-request/264629
---
*products versions - webMethods Integration Server version: 10.7 and above*

## Overview
The OpenAPI Specification (OAS) is an API description format for the REST APIs.
The OpenAPI Specification is widely accepted by the industry and is used by millions of developers and organizations for developing their APIs, be it internal or client-facing. 
Generally, OpenAPI definitions are in YAML or JSON. 

## Use Cases
How to build an OpenAPI request?
Consider the use case where the provider shares the OpenAPI document, and the consumer wants to invoke the REST API that the provider exposes. The consumer needs to build an OpenAPI request using the OpenAPI document. 
The use case starts when the provider sends the OpenAPI document that is ready for consumption and ends when the consumer receives the successful response of the API.

### Actors
1. A client that invokes the REST API.
2. Integration server that acts as a service provider.

### Pre-requisite

1. The consumer must have an OpenAPI document from the provider to invoke the REST APIs.

## Basic Workflow
1. From the OpenAPI document, identify the APIs that you want to invoke.
2. Identify the server details from the <server> element, which specifies the hosted services. The server details can either be specific to the operation that you want to invoke or common across all the APIs defined in the OpenAPI document.
3. Use any REST client.
* Build the REST API request in the following format: 

Format - < URL_of_the_API_server >/< resource_path >
Element in the OpenAPI document - < servers.url >/< paths >

Example, “http://127.0.0.1:5555/pet/findByStatus”

* In the Rest request, set the HTTP method to be used.
* Set the path parameters, query string, and header parameters for the REST API as defined in the OpenAPI document. For more information, see [Building Request Parameters](https://tech.forums.softwareag.com/t/building-request-parameters-request-body-for-an-openapi-request/264596).
* If the REST API defines a requestBody, add the request body and set the Media Type as defined in the OpenAPI document for the API as a content-type header. For more information, see [Building Request Bodies](https://tech.forums.softwareag.com/t/building-request-parameters-request-body-for-an-openapi-request/264596).
* If the REST API defines a response, set the Media Type as defined in the OpenAPI document for the API as an accept header. 
* Set the authentication type for the API as defined in the OpenAPI document.


### Post-conditions

1. The REST client must receive the response for the API as defined in the OpenAPI document.

## References
* [OpenAPI Specification - Version 3.0.2](https://swagger.io/specification/)

* [REST Capabilities in Integration Server](https://tech.forums.softwareag.com/t/rest-capabilities-in-integration-server/237435)

* [Integration Server as a Contract-First REST API Provider using OpenAPI](https://tech.forums.softwareag.com/t/rest-capabilities-in-integration-server/237435)
* [https://documentation.softwareag.com/webmethods/microservices_container/msc10-7/10-7_MSC_PIE_webhelp/index.html#page/integration-server-integrated-webhelp%2Frad_edit_9.html%23wwconnect_header](https://documentation.softwareag.com/webmethods/microservices_container/msc10-7/10-7_MSC_PIE_webhelp/index.html#page/integration-server-integrated-webhelp%2Frad_edit_9.html%23wwconnect_header)

[Read full topic](https://tech.forums.softwareag.com/t/building-open-api-request/264629)