title: Converting post curl to node request
body: <p>I would like to convert this curl call:</p>
  
  <pre><code>curl -d "api_token=PUT_YOUR_API_KEY_HERE&amp;api_action=subscription_datafeed" https://example.foxycart.com/api
  </code></pre>
  
  <p>To node using the request lib - <a href="https://github.com/mikeal/request" rel="nofollow">https://github.com/mikeal/request</a> but I am having issues getting the body sent. My curl call works fine but when I convert it I keep getting the same error about api_token and api_action missing.  Here's what I tried:</p>
  
  <pre><code>var options = {
    url: 'https://example.foxycart.com/api',
    body: JSON.stringify({
      api_token:'PUT_YOUR_API_KEY_HERE',
      api_action:'subscription_datafeed'
    }),
    method: 'POST'
    };
  
  request(options, function (error, response, body) { });
  </code></pre>
  
  <p>Also:</p>
  
  <pre><code>var options = {
    url: 'https://example.foxycart.com/api',
    json: {
      api_token:'PUT_YOUR_API_KEY_HERE',
      api_action:'subscription_datafeed'
    },
    method: 'POST'
    };
  
  request(options, function (error, response, body) { });
  </code></pre>
  
  <p>Also this:</p>
  
  <pre><code>var options = {
    url: 'https://example.foxycart.com/api',
    body: '?api_token=PUT_YOUR_API_KEY_HERE&amp;api_action=subscription_datafeed',
    method: 'POST'
    };
  
  request(options, function (error, response, body) { 
  </code></pre>
  
  <p>Also this:</p>
  
  <pre><code>var options = {
    url: 'https://example.foxycart.com/api',
    body: 'api_token=PUT_YOUR_API_KEY_HERE&amp;api_action=subscription_datafeed',
    method: 'POST'
    };
  
  request(options, function (error, response, body) { 
  </code></pre>
  
  <p>And this:</p>
  
  <pre><code>request.post('https://example.foxycart.com/api?api_token=PUT_YOUR_API_KEY_HERE&amp;api_action=subscription_datafeed', function (error, response, body) { });
  </code></pre>
  
  <p>Here's a PHP one that supposedly works for a similar call on same API - seems like I have the code correct but...</p>
  
  <pre><code>$foxy_domain = "myfoxydomain.foxycart.com";
  $foxyData = array();
  $foxyData["api_token"] = "XXXXX your api / datafeed key here XXXXXX";
  $foxyData["api_action"] = "customer_save";
  $foxyData["customer_id"] = "12345";
  // OR use the email:
  //$foxyData["customer_email"] = "customer@example.com";
  $foxyData["customer_password"] = "my new password";
  
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, "https://" . $foxy_domain . "/api");
  curl_setopt($ch, CURLOPT_POSTFIELDS, $foxyData);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
  curl_setopt($ch, CURLOPT_TIMEOUT, 15);
  </code></pre>
  
  <p>Any ideas?</p>