The following topic demonstrates how to define multiple response codes for the IMS phone
book API methods. The following steps in this topic are optional.
Before you begin
Ensure your API project is open in the IBM® z/OS® Connect
API editor. You can do this by
double-clicking the package.xml
file for your IMS contacts API project in the
Project Explorer view.Ensure that your phone book service is assigned to
your GET and POST API methods.
About this task
In this step, you will define response codes with unique response data mapping for each of
the GET and POST API methods.Note: The response mapping is effective only if the request completes
with a HTTP status code of 300 or lower.
Procedure
- In the API editor,
for the GET method, click
to open the response details for the GET API method.
- Click Add Response
The Add Response window
opens.
- Specify a response code of 404, and specify the following
rules:
- For Rule 1, specify
IVTNO_OUTPUT_MSG/OUT_MESSAGE
as the service
field. Select Starts with for the comparison operator. Enter
SPECIFIED PERSON
for the comparison value. Click the Add
Rule () button to
add a new rule, and specify the logical operator AND
next to Rule
1.
- For Rule 2, specify
IVTNO_OUTPUT_MSG/OUT_MESSAGE
as the service
field. Select Ends with for the comparison operator. Enter NOT
FOUND
for the comparison value.
- Click OK. Save your changes, click
(Ctrl-S).
- Define a unique response mapping for the 404 response.
- Click next to the 404 response.
The field mapping
editor opens.
- Under the Body - response section, right-click each of the
following fields and select Add Remove transform:
- lastName
- firstName
- extension
- zipcode
- Save your response mapping changes, click
(Ctrl-S). Close
the field mapping editor.
- In the API editor,
under the Responses section for the POST method, click
the Add Response button.
The Add Response window
opens.
- Specify a response code of 409, and specify the following
rule:
- For Rule 1, specify
IVTNO_OUTPUT_MSG/OUT_MESSAGE
as the service
field. Select Contains for the comparison operator. Enter ENTRY
EXISTS
for the comparison value.
- Click OK.
- Ensure response code 200 is set as the default response code for the POST method if it is
not already set.
- Click the Response button for the 200 response
code.
- Click Set Response 200 As Default
- Save your changes to your API project by Clicking
(Ctrl-S).
Results
You have configured multiple response codes for your phone book
API GET and POST methods, your GET method has also been configured with a unique response mapping.
Your API is now ready to deploy.