MakeHttpRequest@1
Node MakeHttpRequest@1
is used to make HTTP requests to external APIs or services and store the response in the data pipeline payload. This node supports various HTTP methods, path parameters, headers, and request bodies, making it suitable for integrating with REST APIs and web services.
- The response from the HTTP request is stored at the specified target path in the payload.
- Supports dynamic URL construction using path parameters.
- Allows setting custom headers for authentication and content type requirements.
Adapter Prerequisites
Node Configuration
For fields path
, targetPath
, targetValueWriteMode
, and targetValueKind
, see Overview.
transformations:
- type: MakeHttpRequest@1
targetPath: _httpResponse # Path where the HTTP response should be stored in the payload
method: GET # HTTP method to use (GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS)
url: https://api.example.com/users/{userId} # The URL to make the request to
urlPath: $.apiUrl # Alternative: path to URL in payload
body: '{"name": "John", "email": "john@example.com"}' # Request body for non-GET requests
bodyPath: $.requestBody # Alternative: path to body content in payload
pathParameters: # Parameters to replace in URL placeholders
- name: userId
valuePath: $.user.id # Get user ID from payload
- name: companyId
value: "12345" # Static company ID value
headerParameters: # HTTP headers to include in request
- name: Authorization
valuePath: $.authToken # Get auth token from payload
- name: Content-Type
value: "application/json" # Static content type header
- name: User-Agent
value: "OctoMesh-Adapter/1.0" # Static user agent
Configuration Properties
-
method
(string): The HTTP method to use for the request. Valid values are:GET
,POST
,PUT
,DELETE
,PATCH
,HEAD
,OPTIONS
. Default isGET
. -
url
(string?): The URL to make the HTTP request to. Can contain path parameters in the format{parameterName}
that will be replaced by values frompathParameters
. -
urlPath
(string?): The JSON path to the URL in the payload. This property can be defined instead of theurl
property. -
body
(string?): The request body content as a string. Only used for non-GET requests (POST, PUT, PATCH, DELETE). -
bodyPath
(string?): The JSON path to the request body content in the payload. This property can be defined instead of thebody
property. -
pathParameters
(List<HttpPathParameter>): A list of path parameters to replace URL placeholders. Each parameter has:name
(string): The name of the path parameter (matches{name}
in URL)value
(string?): Static value for the parametervaluePath
(string?): JSON path to get the parameter value from payload
-
headerParameters
(List<HttpHeaderParameter>): A list of HTTP headers to include in the request. Each header has:name
(string): The name of the HTTP header (e.g., "Authorization", "Content-Type")value
(string?): Static value for the headervaluePath
(string?): JSON path to get the header value from payload
Usage Example
Here's an example of how you might use the MakeHttpRequest@1
node in a transformation pipeline:
transformations:
- type: MakeHttpRequest@1
targetPath: _apiResponse # Store the HTTP response in this path
targetValueKind: String # Store response as string
targetValueWriteMode: Replace # Replace any existing value
method: POST # Use POST method
url: https://api.weatherservice.com/v1/locations/{locationId}/readings
pathParameters:
- name: locationId
valuePath: $.sensor.locationId # Get location ID from sensor data
headerParameters:
- name: Authorization
valuePath: $.credentials.apiKey # Get API key from credentials
- name: Content-Type
value: "application/json" # Set content type to JSON
- name: X-Client-Version
value: "1.0.0" # Set client version header
bodyPath: $.sensorReading # Get request body from sensor reading data
In this example:
- We are making a POST request to a weather service API.
- The
locationId
in the URL is dynamically replaced with a value from the payload. - Authentication is handled via an API key header retrieved from the payload.
- The request body contains sensor reading data from the payload.
- The API response is stored in the
_apiResponse
field for further processing.
Advanced Usage Example
Here's a more complex example showing authentication and error handling:
transformations:
# First, prepare authentication token
- type: MakeHttpRequest@1
targetPath: _authToken
targetValueKind: String
targetValueWriteMode: Replace
method: POST
url: https://auth.example.com/token
headerParameters:
- name: Content-Type
value: "application/x-www-form-urlencoded"
body: "grant_type=client_credentials&client_id=your_client_id&client_secret=your_secret"
# Then use the token to make the actual API call
- type: MakeHttpRequest@1
targetPath: _userData
targetValueKind: String
targetValueWriteMode: Replace
method: GET
url: https://api.example.com/users/{userId}
pathParameters:
- name: userId
valuePath: $.user.id
headerParameters:
- name: Authorization
valuePath: $._authToken # Use token from previous request
- name: Accept
value: "application/json"
Notes
- If both the direct value and the corresponding path are provided for a property (e.g., both
url
andurlPath
), the direct value takes precedence. - For non-GET requests, if no body is provided (neither
body
norbodyPath
), the request will be sent without content. - Path parameters in the URL are case-insensitive when being replaced.
- If a path parameter value is null or empty, a warning will be logged but the request will still proceed.
- HTTP headers that cannot be added (due to restrictions or invalid values) will log a warning but won't stop the request.
- The response content is always stored as a string, regardless of the actual content type returned by the server.
- If the HTTP request fails (non-success status code), an error will be logged and the pipeline processing will stop for that item.