Adding an endpoint with the Get method type
Use the Get method to retrieve information from an API.
- Sign in to the Rhythm website as a site editor or tenant administrator.
- Click the Menu button.
- Click the Control Panel tab.
- Click Generic API.
- Click the name of the API.
- Click Add Endpoint.
- In the Incoming URL field, specify the last part of the URL that the generic wrapper uses to identify the endpoint. This value must be unique in the tenant.
- Click the Get method type.
-
In the Parameter Template field,
optionally specify json code that retrieves key values that you can include in
the GET call to the ION API. You can use these types:
- Lookup
- Use this replacement type to look up a value from another
API to use in the GET call.
{ "customerID": { "type": "lookup", "call": "/delegate/ecom-api/users/current", "path": "$.activeUserGroup.customerNumber" } }
In the sample code,
/delegate/ecom-api/users/current
is called. In the results, the user ID that was passed from the API wrapper is searched for in theactiveUserGroup
key. The value in thecustomerNumber
key is returned. If the value in thecustomerNumber
key isABC-123
, then the template results in this json:{ "customerID": "ABC-123" }
This table shows the components of the sample json template:Component Description "customerID" The key to use for the result of the json call. "type" The type of replacement. Specify "type":"lookup"
."call" The call to the API that you are using to look up information. The value that you specify is appended to the base URL for your Rhythm server. "path" The json path expression to use to look up a value in the result of the call. Specify an expression that returns one result. - Input
- Use this replacement type to input a value from the data
that was passed from the API wrapper.
{ "itemID": { "type": "input", "path": "$.itemNumber" } }
In the sample code, the data that was passed from the API wrapper is searched for the
itemNumber
key. If the value in theitemNumber
key is12345
, then the template results in this json:{ "itemID": "12345" }
This table shows the components of the sample json template:Component Description "itemID" The key to use for the result of the json call. "type" The type of replacement. Specify "type":"input"
."path" The json path expression to use to look up a value in the data sent in the API wrapper. Specify an expression that returns one result. - Static value
- Use this template to send a specific value in the API call.
{ "color": "blue" }
In the sample code,
blue
is also sent in thecolor
key.
-
In the URL Template field, specify
the endpoint to call. If you specified information in the Parameter Template field, include the key in
brackets. For example, specify
/example/{itemID}
- Click Save.