title: iMacros Http POST to API endpoint
body: <p>I want to do an <code>HTTP POST</code> from inside an iMacro to an API endpoint. Effectively, something like the following:</p>
  
  <pre><code>curl -d "data=foo" http://example.com/API
  </code></pre>
  
  <p>In iMacros, it might look something like this:</p>
  
  my-imacro.iim
  
  <pre><code>VERSION BUILD=10.4.28.1074
  TAB T=1
  URL GOTO=javascript:post('http://example.com/API', {data: 'foo'});
    function post(path, params, method) {
      // Reference: http://stackoverflow.com/a/133997/1640892
      method = method || "post";
      var form = document.createElement("form");
      form.setAttribute("method", method);
      form.setAttribute("action", path);
      for (var key in params) {
        if (params.hasOwnProperty(key)) {
          var hiddenField = document.createElement("input");
          hiddenField.setAttribute("type", "hidden");
          hiddenField.setAttribute("name", key);
          hiddenField.setAttribute("value", params[key]);
          form.appendChild(hiddenField);
        }
      }
      document.body.appendChild(form);
      form.submit();
    }
  </code></pre>
  
  <p>But the above seems like a long and difficult way to do this. If it even works.</p>
  
  <p>Is there a shorter, more direct or efficient solution?</p>