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.

Interface

The DPC must implement /neptune/if_dxp_api_dpc.

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

API path set in Hub API Designer

operation

Operation path set in Hub API Designer

method

HTTP method used for this call

form_fields

Table of all form (query) fields in the request

header_fields

Table of all header fields in the request

body

String body data (when data is in text format)

body_x

Binary body data (when data is in binary format)

multiparts

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

content

Text response content

content_x

Binary response content

content_type

Response content type

status_code

HTTP response status code

status_text

HTTP response status text

status_message

Status message

cookies

Table of cookie adjustments

headers

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.