robocorp-actions
Getting request data (such as headers) in Actions
Starting with robocorp-actions 0.1.0
, it's possible to collect data from the
received request by creating a request: Request
argument in the @action
.
The data currently available in the request is:
headers
: contains all the headers received.cookies
: contains all the cookies received in headers in a dict-like API.
Note that the access to headers and cookies is case-insensitive.
Example:
from robocorp.actions import action, Request
@action
def my_action(request: Request):
header: Optional[str] = request.headers.get('X-custom-header')
cookie: Optional[str] = request.cookies.get('X-custom-cookie')
Note: for testing it's possible to set the request
(with its headers
and cookies
)
using the --json-input
.
In a production environment it'll be provided by the Action Server.
Getting secrets in Actions
Starting with robocorp-actions 0.2.0
, it's possible to receive
secrets as arguments in the @action
.
The requisite for that is adding an argument and typing it with the Secret
type.
Example:
from robocorp.actions import action, Secret
@action
def my_action(my_secret: Secret):
login(secret.value)
When developing, it's possible to specify the secret directly in the json input as a string.