Invoke a POST method on an application
POSThttps://http-prj1234.api.cloud.diagrid.io/v1.0/invoke/:appId/method/:methodName
This endpoint lets you invoke a HTTP POST method on another application.
Request
Path Parameters
appId stringrequired
Possible values: Value must match regular expression ^[a-zA-Z0-9_-]+$
methodName stringrequired
Possible values: Value must match regular expression ^[a-zA-Z0-9_-]+$
- application/json
Body
required
object
Responses
- 200
- 400
- 403
- 500
OK.
Method name not given.
Invocation forbidden by access control.
Request failed.
- python
- java
- csharp
- nodejs
- go
- Python
# pip3 install dapr certifi requests
# ---
from dapr.clients import DaprClient
import os
os.environ["DAPR_API_TOKEN"] = "{{ .DaprAPIToken }}"
os.environ["DAPR_HTTP_ENDPOINT"] = "{{ .DaprHTTPEndpoint }}"
os.environ["DAPR_GRPC_ENDPOINT"] = "{{ .DaprGRPCEndpoint }}"
with DaprClient() as d:
resp = d.invoke_method("{{ .AppID }}", "test", data="{\"key\":\"value\"}", http_verb="{{ .Operation }}")
print(resp.data)
- REQUESTS
- HTTP.CLIENT
import requests
import json
url = "https://http-prj1234.api.cloud.diagrid.io/v1.0/invoke/:appId/method/:methodName"
payload = json.dumps({})
headers = {
'Content-Type': 'application/json',
'dapr-api-token': '<API_KEY_VALUE>'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
ResponseClear