Skip to main content

Save state item

POST 

https://http-prj1234.api.cloud.diagrid.io/v1.0/state/:storeName

This endpoint lets you save multiple items to the state store.

Request

Path Parameters

    storeName stringrequired

    Possible values: Value must match regular expression ^[a-zA-Z0-9_-]+$

    The name of your state store.

Body

array

required

  • Array [

  • key stringrequired

    Possible values: Value must match regular expression ^[a-zA-Z0-9_-]+$

    value objectrequired
    etag string

    metadata

    object

    ttlInSeconds string

    Possible values: <= 6 characters, Value must match regular expression ^[0-9]+$

    property name* string

    options

    object

    property name* any
  • ]

Responses

State saved.

# 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:
d.save_state(store_name="{{ .KVStore }}", key="mykey", value="myvalue")
import requests
import json

url = "https://http-prj1234.api.cloud.diagrid.io/v1.0/state/:storeName"

payload = json.dumps([
{
"key": "string",
"value": {
"name": "John Doe",
"age": 30
},
"etag": "",
"metadata": {
"ttlInSeconds": "string"
},
"options": {}
}
])
headers = {
'Content-Type': 'application/json',
'dapr-api-token': '<API_KEY_VALUE>'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)
Request Collapse all
Base URL
https://http-prj1234.api.cloud.diagrid.io
Auth
Parameters
— pathrequired
Body required
[
  {
    "key": "string",
    "value": {
      "name": "John Doe",
      "age": 30
    },
    "etag": "",
    "metadata": {
      "ttlInSeconds": "string"
    },
    "options": {}
  }
]
ResponseClear

Click the Send API Request button above and see the response here!