REST
Request
typescriptCopied1import airplane from "airplane";23export default airplane.task(4{5slug: "update_user_profile",6name: "Update user profile",7resources: ["profile_api"],8},9async () => {10const run = await airplane.rest.request<{ userId: string; avatar: string }>(11// Slug of the REST resource to query12"profile_api",13// REST method to execute14"POST",15// URL path16"/profile",17// Options18{19// Request body20body: {21name: "Bob",22job: "Engineer",23},24// Body type25bodyType: "json",26},27);28return run.output.response;29},30);
Slug of REST resource to use. See Resources.
The REST API method.
Optional path to append to the base URL configured in the REST resource.
Optional request body.
Optional body content type.
Optional object containing request headers.
Optional form data.
Optional object containing URL parameters.
True to retry the request on 500, 502, 503, and 504 error codes. Requests will always be retried on 408 and 429 error codes.
The return value from the rest call.
pythonCopied1import airplane23@airplane.task(4slug="update_user_profile",5name="Update user profile",6resources=[7airplane.Resource(8slug="profile_api",9)10],11)12def update_user_profile():13run = airplane.rest.request(14# Slug of the REST resource to query15rest_resource="profile_api",16# REST method to execute17method="POST",18# URL path19path="/profile",20# Body type21body_type=airplane.rest.BodyType.JSON,22# Request body23body={24"name": "Bob",25"job": "Engineer"26}27)28return run.output["response"]
Slug of REST resource to use. See Resources.
The HTTP method of the request.
The path of the request.
Optional headers to include in the request.
Optional URL params to include in the request.
The type of the body if provided. BodyType
is an Enum
and its options are: UNKNOWN
, JSON
, RAW
, FORM_DATA
, FORM_URL_ENCODED
The request body to include in the request.
The form data to include in the request.
True to retry 500, 502, 503, and 504 error codes.
The return value from the rest call.
If the prompt cannot be created properly.
If the run fails or is cancelled.