Modifying API mocking details
About this task
You can modify API mocking details, as required, from the API details page.
Procedure
- Open the menu options and select APIs. A list of all registered APIs appears.
- Click an API. The API details page appears.
- Click Edit.
- Click API mocking.
- Specify the following information in the IS service section.
Field Description Invoke service Specifies the webMethods Integration Server service to be invoked. Run as user Type the username that you want webMethods API Gateway to use to invoke the IS service. - Select the operation that you want to modify from the Mocked responses section.
- Click Add Response if you want to add a response and select the status code from the list.
- Click +Add to add the status code that you created to the existing status code list.
- Select the status code that you want to modify.
- Click + Add Response Header and provide the following information
to add the required response headers.
Field Description Header key Specify the HTTP header key to be contained in the header of the HTTP response. Header value Specify the HTTP header value to be contained in the header of the HTTP response. You can add more response headers by clicking +Add.
- Click + Add Content-type to add a content-type to the status code
selected and provide the following information.
Field Description Content type Select the content-type to be added to the selected status code from the list. Mock payloads Specify a mock response payload for the content-type selected. You can add more content-types by clicking Add.
- Click + Add Conditions to add a condition to the operation in the
resource and provide the following information.
Field Description Condition name Specify the name for the condition. Condition parameter Select the type to which you want to apply the condition. The available options are as follows. - Body
- Header
- Query parameter (Applicable only for REST APIs)
Key The key can be a string for the header and query parameter and for body it can be a JSON path or an XML path. Value The value of the condition. Also, you can type an * (asterisk) to ignore the value that is specified in this parameter. The condition is satisfied based on the value that is specified in the Key parameter. Status code Select the status code from the list. Note:- Enable the property Send native provider fault in the Administration > General > API fault section to have a correct mock response for status code 506.
- When you invoke an API, remember to use the query parameter
expectedStatusCode
to have correct mock responses for status codes 100 and 202.
+ Add Response Header Add a response header to the resource by providing the following information. - Header key. Specify the HTTP header key to be contained in the header of the HTTP response
- Header value. Specify the HTTP header value to be contained in the header of the HTTP response.
+ Add Content-type Add a content-type to the status code by providing the following information. - Content type. Select the content-type to be added to the selected status code from the list.
- Mock payload. Specify a mock response payload for the content-type selected.
You can add more conditions by clicking Add.
- Click Save.