This article demonstrates how to call a non-Dapr endpoint using Dapr over HTTP.
Using Dapr’s service invocation API, you can communicate with endpoints that either use or do not use Dapr. Using Dapr to call endpoints that do not use Dapr not only provides a consistent API, but also the following Dapr service invocation benefits:
Sometimes you need to call a non-Dapr HTTP endpoint. For example:
By defining an HTTPEndpoint
resource, you declaratively define a way to interact with a non-Dapr endpoint. You then use the service invocation URL to invoke non-Dapr endpoints. Alternatively, you can place a non-Dapr Fully Qualified Domain Name (FQDN) endpoint URL directly into the service invocation URL.
When using service invocation, the Dapr runtime follows a precedence order:
HTTPEndpoint
resource?http://
or https://
prefix?appID
?The diagram below is an overview of how Dapr’s service invocation works when invoking non-Dapr endpoints.
HTTPEndpoint
or FQDN URL then forwards the message to Service B.There are two ways to invoke a non-Dapr endpoint when communicating either to Dapr applications or non-Dapr applications. A Dapr application can invoke a non-Dapr endpoint by providing one of the following:
A named HTTPEndpoint
resource, including defining an HTTPEndpoint
resource type. See the HTTPEndpoint reference guide for an example.
localhost:3500/v1.0/invoke/<HTTPEndpoint-name>/method/<my-method>
For example, with an HTTPEndpoint
resource called “palpatine” and a method called “Order66”, this would be:
curl http://localhost:3500/v1.0/invoke/palpatine/method/order66
A FQDN URL to the non-Dapr endpoint.
localhost:3500/v1.0/invoke/<URL>/method/<my-method>
For example, with an FQDN resource called https://darthsidious.starwars
, this would be:
curl http://localhost:3500/v1.0/invoke/https://darthsidious.starwars/method/order66
AppIDs are always used to call Dapr applications with the appID
and my-method
. Read the How-To: Invoke services using HTTP guide for more information. For example:
localhost:3500/v1.0/invoke/<appID>/method/<my-method>
curl http://localhost:3602/v1.0/invoke/orderprocessor/method/checkout
Using the HTTPEndpoint resource allows you to use any combination of a root certificate, client certificate and private key according to the authentication requirements of the remote endpoint.
apiVersion: dapr.io/v1alpha1
kind: HTTPEndpoint
metadata:
name: "external-http-endpoint-tls"
spec:
baseUrl: https://service-invocation-external:443
headers:
- name: "Accept-Language"
value: "en-US"
clientTLS:
rootCA:
secretKeyRef:
name: dapr-tls-client
key: ca.crt
apiVersion: dapr.io/v1alpha1
kind: HTTPEndpoint
metadata:
name: "external-http-endpoint-tls"
spec:
baseUrl: https://service-invocation-external:443
headers:
- name: "Accept-Language"
value: "en-US"
clientTLS:
certificate:
secretKeyRef:
name: dapr-tls-client
key: tls.crt
privateKey:
secretKeyRef:
name: dapr-tls-key
key: tls.key
SSE enables real-time communication with streaming servers and MCP servers.
HTTP endpoints support Server-Sent Events (SSE).
To use SSE, set the Accept
header to text/event-stream
in the HTTPEndpoint
resource or in the service invocation request.
apiVersion: dapr.io/v1alpha1
kind: HTTPEndpoint
metadata:
name: "mcp-server"
spec:
baseUrl: https://my-mcp-server:443
headers:
- name: "Accept"
value: "test/event-stream"
Watch this video on how to use service invocation to call non-Dapr endpoints.