Data provider class in the Hub API Designer
This page covers how the data provider class (DPC) is configured and used within the Hub API Designer, where each API operation is connected to a public DPC method and request and response data is handled through bindings.
Methods and bindings
Each operation in the Hub API Designer is connected to one public method in the DPC. Bindings can be set up using method signature parameters, public attributes, or a combination of both. These are populated automatically with matching data sent in the call to the Hub API operation. Conversely, the response is automatically populated with the corresponding data from the DPC.
It is also possible to handle request data, response data, or both manually.
Request data
When a Hub API operation is called, data related to the call is populated into
the /neptune/if_dxp_api_dpc~data_request structure. In typical use cases with
regular DPC bindings, there is no need to read this data manually. For manual use
cases, the following fields are available:
Request data table
| Field | Content |
|---|---|
|
API path set in Hub API Designer |
|
Operation path set in Hub API Designer |
|
HTTP method used for this call |
|
Table of all form (query) fields in the request |
|
Table of all header fields in the request |
|
String body data (when data is in text format) |
|
Binary body data (when data is in binary format) |
|
Table of multiparts (when data is in multipart format) |
Response data
The response can be manually set by populating the /neptune/if_dxp_api_dpc~data_response
structure. In typical use cases with regular DPC bindings, this is not necessary.
For manual use cases, where the /neptune/if_dxp_api_dpc~data_response structure
must be populated to set the response, the following fields are available:
Response data table
| Field | Content |
|---|---|
|
Text response content |
|
Binary response content |
|
Response content type |
|
HTTP response status code |
|
HTTP response status text |
|
Status message |
|
Table of cookie adjustments |
|
Table of header adjustments |
Manually setting content, even if a DPC response binding is specified, will
override the binding and send the manual content in the response. Set either the
text-based content or binary content_x based on the response content type.
If no status code is manually set, the default 200 OK will be sent. If a status
code is set but the content is left empty, the content will be set to a JSON
representation of the status_code, status_text, and status_message, formatted
as errorCode.
It is also possible to define the /neptune/cx_dxp_http exception in your method
signature and raise it with the appropriate status_code, status_text, and
status_message values. This will abort execution, set the specified HTTP status,
and return the errorCode JSON in the response.
The cookies and headers tables can be used to add or delete cookies and headers
at the client.