title: nodeJS request library: making POST request with surrogate key instead of URL
body: <p>I am trying to use nodeJS request library to issue a POST request to purge content associated with a certain <a href="https://developer.fastly.com/reference/api/purging/#purge-all" rel="nofollow noreferrer">surrogate key via Fastly API</a>. The POST request would look something like this:</p>
  <pre><code>POST /service/SU1Z0isxPaozGVKXdv0eY/purge
  Content-Type: application/json
  Accept: application/json
  Fastly-Key: YOUR_FASTLY_TOKEN
  Fastly-Soft-Purge: 1
  Surrogate-Key: key_1 key_2 key_3
  </code></pre>
  <p>I tried to do this in node.JS two different ways.</p>
  <p>The first:</p>
  <pre><code>    // perform request to purge
      request({
          method: `POST`,
          url: `/service/${fastly_service_id}/purge${surrogateKeyArray[i]}`, 
          headers: headers,
      }, function(err, response, body) {
          // url was not valid to purge
          if (err) {
              console.log(&quot;is there an err???&quot;)
              console.log(err)
          }
      })
      }
  </code></pre>
  <p>I get, <code>Error: Invalid URI: /service/&lt;fastly_Service_id&gt;/purge/&lt;surrogate_key&gt;</code></p>
  <p>I double checked my surrogate key via <code>curl -s -I -H &quot;Fastly-Debug: 1&quot; &lt;URL corresponding to surrogate key&gt; | grep surrogate-key</code></p>
  <p>And it returns the same surrogate-key used in my code.</p>
  <p>In the second attempt, I tried:</p>
  <pre><code>    // perform request to purge
      request({
          method: `POST /service/${fastly_service_id}/purge${surrogateKeyArray[i]}`,
          headers: headers,
      }, function(err, response, body) {
          // url was not valid to purge
          if (err) {
              console.log(&quot;is there an err???&quot;)
              console.log(err)
          }
      })
      }
  </code></pre>
  <p>I get the error, <code>Error: options.uri is a required argument</code></p>