SOA Governance and API Management : Working with REST-based APIs : Creating a RESTful API from Scratch : Adding Base URL to REST API
Adding Base URL to REST API
After you define the REST API, you then expose the API's base URLs. A base URL path includes the hostname of the server where the API is actually hosted.
Pre-requisites
When you configure the global details for an API, keep the following points in mind:
*A base URL is the core design element that serves as the only way to access the identified API.
CentraSite allows you to configure multiple base URL paths for the API. For example, you can configure a sandbox URL for testing purposes and a production URL for accessing real-world data.
For our sample Phone Store API, here are the sandbox and production base URLs:
Sandbox URL
https://www.sandbox.phonestore.com/api/v2
Production URL
https://www.phonestore.com/api/v2
For example, a base URL for our sample Phone Store API would look like:
https://www.phonestore.in/api/v2
A complete URL is formed by combining the resource path with the base URL.
For example, here is the URL you would use in a request to get the list of phones:
GET https://www.phonestore.in/api/v2/phones
Or, retrieve a phone with product code is 412456
GET https://www.phonestore.in/api/v2/phones/phone-412456
Where,
GET - HTTP request method
https://www.phonestore.in/api/v2 - URL
phones - resource URI
412456 - path parameter
*An API parameter is an expression that represents a value that the client passes to the API specified in the client call. Here, the parameters are specified at the API level. Since these are defined at the API level, the parameters will be available for all child resources and methods below the API in the hierarchy.
Configure the base URLs for the API using which users would traverse to any of the API's resources. In order to execute this task, you must know the URL of the server that is hosting the API you intend to model.
To add a base URL
1. Display the details page of the REST API (see Viewing the Details of a REST API for details).
2. In the actions bar for the API, click the Edit icon.
3. Select the Technical Details profile.
4. Enter the following information in the fields provided:
In this field...
Do the following...
Base URL
Optional. Enter the server base URL in the text box.
Note:  
If you are specifying multiple base URLs for an API, it must be unique among all URLs in the API.
If you want to specify additional base URLs, use the plus button beside the text box to create a new base URL input field, and enter another URL.
If at any time you want to remove a base URL, use the minus button.
Sandbox
Optional. The sandbox category by which you want to classify base URL for the API.
a. Click Choose.
b. When you click the button, the Choose Sandbox Categories dialog appears which allows you to select the required categories for base URL.
c. Click the expand node next to Sandbox taxonomy to view the categorization tree.
d. Mark the checkbox beside the name of the category to classify the base URL.
e. Click OK.
CentraSite includes a set of predefined categories for the taxonomy node "Sandbox", especially for classifying base URLs of REST APIs. By default, the base URLs can be classified into these following predefined categories: Development, Production, Test.
For information on the Sandbox categories that CentraSite supports out-of-the-box, in CentraSite Control, go to Administration > Taxonomies. In the Taxonomies page, navigate to Sandbox in the list of taxonomies.
If you would like to use sandbox categories that are not supported by CentraSite, you can define your custom categories.
Note:  
Although it is possible to define subcategories for the predefined and custom categories within the Sandbox taxonomy, you cannot use these subcategories to classify the base URLs. CentraSite only displays the names of the top-level categories (that is, categories that are defined for the Sandbox taxonomy) for the classification.
Namespace
Optional. Specify the target namespace.
Request Content-Type
Select the content format for request message. (The drop-down list displays the list of supported content formats.)
Note:  
By default, this field shows an empty value.
Response Content-Type
Select the content format for response message. (The drop-down list displays the list of supported content formats.)
Note:  
By default, this field shows an empty value.
Parameters - Add Parameter
Optional. Specify one or more request parameters of the following types at the API level:
*Query-String
*Header
*Form
Although CentraSite allows you to define parameters of the type "Form" at the API level, these parameters are not supported at run-time. Only parameters of the type Query-String and Header are supported at run-time.
Note:  
You cannot add more than one parameter with the same name and the same type within the API level.
a. Click the Add Parameter link to open the Add Parameter dialog.
b. In this dialog, you define input parameters at the API level. To specify multiple parameters, click the Add Parameter link to add each new parameter.
The new parameter is added to the Technical Details profile. For a complete description of how to add the request parameters, see Adding Parameter to REST API.
5. To further update the new parameter, mouse over the parameter, and then click the Edit icon. Repeat for each parameter that you want to modify.
6. To specify multiple parameters, click the Add Parameter link to add each new parameter.
7. After you specify the value for all of the required fields, click the Save icon to save the changes.
Copyright © 2015- 2016 Software AG, Darmstadt, Germany.

Product LogoContact Support   |   Community   |   Feedback