In this article

Add an API manually

08/27/2018

5 minutes to read

Contributors

In this article

The steps in this article show how to use the Azure portal to add an API manually to the API Management (APIM) instance. A common scenario when you would want to create a blank API and define it manually is when you want to mock the API. For details about mocking an API, see Mock API responses.

Go to your API Management instance

To add API Management to your favorites in the Azure portal, select the star.

The API Management icon () now appears in the left menu in the portal.

Create an API

Select APIs from under API MANAGEMENT.

From the left menu, select + Add API.

Select Blank API from the list.

Enter settings for the API.

Name

Value

Description

Display name

"Blank API"

This name is displayed in the Developer portal.

Web Service URL (optional)

"http://httpbin.org"

If you want to mock an API, you might not enter anything. In this case, we enter http://httpbin.org. This is a public testing service. If you want to import an API that is mapped to a back end automatically, see one of the topics in the related topics section.

URL scheme

"HTTPS"

In this case, even though the back end has non-secure HTTP access, we specify a secure HTTPS APIM access to the back end. This kind of scenario (HTTPS to HTTP) is called HTTPS termination. You might do it if your API exists within a virtual network (where you know the access is secure even if HTTPS is not used). You might want to use "HTTPS termination" to save on some CPU cycles.

URL suffix

"hbin"

The suffix is a name that identifies this specific API in this APIM instance. It has to be unique in this APIM instance.

Products

"Unlimited"

Publish the API by associating the API with a product. If you want for the API to be published and be available to developers, add it to a product. You can do it during API creation or set it later.

Products are associations of one or more APIs. You can include a number of APIs and offer them to developers through the developer portal. Developers must first subscribe to a product to get access to the API. When they subscribe, they get a subscription key that is good for any API in that product. If you created the APIM instance, you are an administrator already, so you are subscribed to every product by default.

By default, each API Management instance comes with two sample products: Starter and Unlimited.

Select Create.

At this point, you have no operations in APIM that map to the operations in your back-end API. If you call an operation that is exposed through the back end but not through the APIM, you get a 404.

Note

By default, when you add an API, even if it is connected to some back-end service, APIM will not expose any operations until you whitelist them. To whitelist an operation of your back-end service, create an APIM operation that maps to the back-end operation.

Add and test an operation

This section shows how to add a "/get" operation in order to map it to the back end "http://httpbin.org/get" operation.

Add an operation

Select the API you created in the previous step.

Click + Add Operation.

In the URL, select GET and enter "/get" in the resource.

Enter "FetchData" for Display name.

Select Save.

Test an operation

Test the operation in the Azure portal. Alternatively, you can test it in the Developer portal.

Select the Test tab.

Select FetchData.

Press Send.

The response that the "http://httpbin.org/get" operation generates appears. If you want to transform your operations, see Transform and protect your API.

Add and test a parameterized operation

This section shows how to add an operation that takes a parameter. In this case, we map the operation to "http://httpbin.org/status/200".

Add the operation

Select the API you created in the previous step.

Click + Add Operation.

In the URL, select GET and enter "/status/{code}" in the resource. Optionally, you can provide some information associated with this parameter. For example, enter "Number" for TYPE, "200" (default) for VALUES.

Enter "GetStatus" for Display name.

Select Save.

Test the operation

Test the operation in the Azure portal. Alternatively, you can test it in the Developer portal.

Select the Test tab.

Select GetStatus. By default the code value is set to "200". You can change it to test other values. For example, type "418".

Press Send.

The response that the "http://httpbin.org/status/200" operation generates appears. If you want to transform your operations, see Transform and protect your API.

Append other APIs

An API can be composed of APIs exposed by different services, including the OpenAPI Specification, a SOAP API, the API Apps feature of Azure App Service, Azure Function App, Azure Logic Apps, and Azure Service Fabric.

To append a different API to your existing API, complete the following steps. When you import another API, the operations are appended to your current API.