Send HTTP request
TheSend HTTP requestaction connects your workflow to a web server or URL and sends HTTP requests.
After Flow sends your HTTP request, it waits for a maximum of 30 seconds for anHTTP response code. If Flow hasn't received a response after 30 seconds, then it closes the connection to your app and it resends the request.
On this page
Fields
TheSend HTTP requestaction contains the following fields.
Field | Description |
---|---|
HTTP method | The method of HTTP request to send. TheSend HTTP requestaction supports the following methods:
|
URL | The URL of the server to which the HTTP request is sent. |
Headers | The key and value pair for the HTTP request. Multiple key-value pairs can be entered. |
Body | The content to be sent to the server. |
Triggers
TheSend HTTP requestaction can be used in any workflow.
Examples
Call the Shopify GraphQL Admin API
In this example, you will use Flow to edit a product title by calling theproductUpdateAPI.
Before you begin, do the following:
- Set up and install a Custom Appthat has the
write_products
scope. You will use theAPI Secret Keyto call the API in this example.
Then, follow these steps in Flow:
- Choose theProduct status updatedtrigger, which allows you to test this workflow by changing the status on a product.
- AddSend HTTP Requestto your workflow and connect it to the trigger.
- Open the configuration panel by clicking theSend HTTP Requeststep.
- In theHTTP Methodfield, enter
POST
. - In theURLfield, enter
https://admin.shopify.com/store/shopname/api/2023-01/graphql.json
substituting your shop domain and desired API Version. - In theHeaderssection, enter aKeyof
X-Shopify-Access-Token
andValueofYOUR_API_SECRET_KEY
that you obtained in the first step. - In theHeaderssection, enter a second header withKeyof
Content-Type
andValueofapplication/json
. - In theBodysection, enter the following:
- This code adds
-edited
to the end of your title - Spaces and newlines are meaningful to the Liquid editor, so avoid adding or removing spaces. Also, except for outputting Liquid, avoid collapsing brackets like
{{
and}}
因为他们是预留给液体variables.
- Configure the rest of the workflow and activate it.
- Test it by changing the status on a Product fromDrafttoActiveor vice versa.
Call an External API
In this example workflow, a POST HTTP request is sent to a server when an order is paid.
Response codes
The following table describes how Flow processes theHTTP response codeafter it receives a response.
HTTP response code | How Flow processes the response code |
---|---|
2XX or 3XX Success | Flow marks the HTTP request as a success, and performs subsequent actions in the workflow. |
429 or 5XX Error | Flow automatically retries the action for up to 24 hours until it receives a different response code or it times out. |
Other response code | If your app returns a code that isn't described in this table or it times out while retrying actions, then Flow marks the HTTP request as failing. Subsequent workflow actions are not taken. |