The "http" action

Mechanic's "http" action allows you to send request to third-party APIs. This means Mechanic can be used to translate Shopify data and deliver it to other services.

For developers

Options

  • "method"  – required, must be one of "post" , "put" , "patch" , "delete" 
  • "url"   – required, must be a string starting with http:// or https:// 
  • "headers"  – optional, may be a JSON object of header names and values
  • "body"   – required, may be a string to represent a plain request body, or may be a JSON object to be automatically serialized to JSON
  • "verify" – optional, may be set to false to disable SSL certificate verification

Note: Mechanic will only automatically serialize to JSON if the Content-Type  header is either blank or set to application/json .

Basic authentication

To authenticate your request using the Authorization header, using the "Basic" authentication type, use something like this:

{% assign username = "guest" %}
{% assign password = "guest" %}
{% assign authorization_header = username | append: ":" | append: password | base64 | prepend: "Basic " %}

{% action "http" %}
  {
    "method": "get",
    "url": "https://jigsaw.w3.org/HTTP/Basic/",
    "headers": {
      "Authorization": {{ authorization_header | json }}
    }
  }
{% endaction %}

Example

This task sends the merchant's input to a third-party API that simply echoes it back. Great for testing. ;)

Subscriptions:

mechanic/user/text

Script:

{% action "http" %}
  {
    "method": "post",
    "url": "https://postman-echo.com/post",
    "body": {{ event.data | json }}
  }
{% endaction %}
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.