HTTP binding spec
This component supports output binding with the following HTTP methods/verbs:
create
: For backward compatibility and treated like a postget
: Read data/recordshead
: Identical to get except that the server does not return a response bodypost
: Typically used to create records or send commandsput
: Update data/recordsdelete
: Delete a data/recordoptions
: Requests for information about the communication options available (not commonly used)trace
: Used to invoke a remote, application-layer loop- back of the request message (not commonly used)
Operation metadata fields
All of the operations above support the following metadata fields
Retrieving data
To retrieve data from the HTTP endpoint, invoke the HTTP binding with a GET
method and the following JSON body:
{
}
{
"operation": "get",
"metadata": {
"path": "/things/1234"
}
}
The response body contains the data returned by the HTTP endpoint. The data
field contains the HTTP response body as a byte slice (Base64 encoded via curl). The metadata
field contains:
Example
Requesting the base URL
curl -d '{ "operation": "get" }' \
Requesting a specific path
curl -d "{ \"operation\": \"get\", \"metadata\": { \"path\": \"/things/1234\" } }" \
http://localhost:<dapr-port>/v1.0/bindings/<binding-name>
Note
Any metadata field that starts with a capital letter is passed as a request header. For example, the default content type is application/json; charset=utf-8
. This can be overridden be setting the Content-Type
metadata field.
{
"operation": "post",
"data": "content (default is JSON)",
"metadata": {
"path": "/things",
"Content-Type": "application/json; charset=utf-8"
}
}
Example
Posting a new record
curl -d "{ \"operation\": \"post\", \"data\": \"YOUR_BASE_64_CONTENT\", \"metadata\": { \"path\": \"/things\" } }" \