Form urlencoded

This request format can be declared in any blocks (execute, acquire, fields etc.) in your custom connector code.

Sample code snippet

Let's use the submit data to a form endpoint in HubSpot API as an example. This endpoint accepts form data in form urlencoded format.

A cURL example looks like this:

curl \
  https://forms.hubspot.com/uploads/form/v2/12345/67890 \
  -X POST \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -d 'firstname=TestContact&lastname=FormSub&email=formsub@hubspot.com&newcustomproperty=testing&hs_context=%7B%22hutk%22%3A%2260c2ccdfe4892f0fa0593940b12c11aa%22%2C%22ipAddress%22%3A%22192.168.1.12%22%2C%22pageUrl%22%3A%22http%3A%2F%2Fdemo.hubapi.com%2Fcontact%2F%22%2C%22pageName%22%3A%22Contact%2BUs%22%2C%22redirectUrl%22%3A%22http%3A%2F%2Fdemo.hubapi.com%2Fthank-you%2F%22%7D'

This cURL command can be replicated in Workato:

{
  title: "HubSpot",

  connection: {
    # Some code here
  },

  test: {
    # Some code here
  },

  actions: {
    submit_form: {
      input_fields: lambda do
        [
          {
            name: "portal_id",
            type: "string"
          },
          {
            name: "form_guid",
            type: "string"
          },
          {
            name: "hutk",
            type: "string"
          },
          {
            name: "ipAddress",
            type: "string"
          },
          {
            name: "pageUrl",
            type: "string"
          },
          {
            name: "pageName",
            type: "string"
          },
          {
            name: "redirectUrl",
            type: "string"
          }
        ]
      end,

      execute: lambda do |connection, input|
        post("https://forms.hubspot.com/uploads/form/v2/#{input['portal_id']}/#{input['form_guid']}").
          request_format_www_form_urlencoded.
          request_body(
            input.reject { |k,v| k == 'portal_id' || k == 'form_guid' }
          )
      end
    },

    output_fields: { ... }
  },

  triggers: {
    # Some code here
  },
  object_definitions: {
    # Some code here
  },
  picklists: {
    # Some code here
  },
  methods: {
    # Some code here
  }

Components

cURL Workato
curl https://forms.hubspot.com/uploads/form/v2/{portal_id}/{form_guid} -X POST post("https://forms.hubspot.com/uploads/form/v2/#{input['portal_id']}/#{input['form_guid']}")
-H 'Content-Type: application/x-www-form-urlencoded' .request_format_www_form_urlencoded
-d '{data}' .request_body(input.reject { |k,v| k == 'portal_id' || k == 'form_guid' })

Other data Formats

Check out the other data formats we support. Learn more

Next section

If you're already familiar with the data formats we support, check out the authentication types that our SDK supports as well as how to implement them. Learn more

results matching ""

    No results matching ""