title: httr POST request with auth token in body
body: <p>I am looking to POST an array to create a new profile in an email service provider via their API via the <code>httr</code> package. The API documenation can be found <a href="https://www.klaviyo.com/docs/http-api#identify" rel="nofollow noreferrer">here</a>.</p>
  <p>A copy and paste of the curl command provided via the documentation works, but my implementations are throwing 403. The key was replaced for the purpose of posting here.</p>
  <p>I am really struggling to determine the issue. I'm fairly new to API calls, especially POST and feel there's a core concept I'm missing.</p>
  <p>My attempt:</p>
  <pre><code>identify_body &lt;- '{
    &quot;token&quot; : &quot;public_key_goes_here&quot;,
    &quot;properties&quot; : {
      &quot;$email&quot; : &quot;thomas.jefferson@klaviyo.com&quot;,
      &quot;$first_name&quot; : &quot;Thomas&quot;,
      &quot;$last_name&quot; : &quot;Jefferson&quot;,
      &quot;Plan&quot; : &quot;Premium&quot;,
      &quot;SignUpDate&quot; : &quot;2016-05-01 10:10:00&quot;
    }
  }'
  
  httr::POST(&quot;https://a.klaviyo.com/api/identify&quot;,
             body = identify_body, 
             content_type_json(), 
             verbose())
  </code></pre>
  <p>Results:</p>
  <pre><code>-&gt; POST /api/identify HTTP/1.1
  -&gt; Host: a.klaviyo.com
  -&gt; User-Agent: libcurl/7.59.0 r-curl/3.3 httr/1.4.0
  -&gt; Accept-Encoding: gzip, deflate
  -&gt; Accept: application/json, text/xml, application/xml, */*
  -&gt; Content-Type: application/json
  -&gt; Content-Length: 222
  -&gt; 
  &gt;&gt; {
  &gt;&gt;   &quot;token&quot; : &quot;public_key_goes_here&quot;,
  &gt;&gt;   &quot;properties&quot; : {
  &gt;&gt;     &quot;$email&quot; : &quot;thomas.jefferson@klaviyo.com&quot;,
  &gt;&gt;     &quot;$first_name&quot; : &quot;Thomas&quot;,
  &gt;&gt;     &quot;$last_name&quot; : &quot;Jefferson&quot;,
  &gt;&gt;     &quot;Plan&quot; : &quot;Premium&quot;,
  &gt;&gt;     &quot;SignUpDate&quot; : &quot;2016-05-01 10:10:00&quot;
  &gt;&gt;   }
  &gt;&gt; }
  
  &lt;- HTTP/1.1 403 Forbidden
  &lt;- Content-Encoding: gzip
  &lt;- Content-Type: text/html
  &lt;- Date: Mon, 04 Jan 2021 22:02:12 GMT
  &lt;- Server: nginx
  &lt;- Vary: Accept-Encoding
  &lt;- Vary: Cookie
  &lt;- Content-Length: 779
  &lt;- Connection: keep-alive
  &lt;- 
  Response [https://a.klaviyo.com/api/identify]
    Date: 2021-01-04 22:02
    Status: 403
    Content-Type: text/html
    Size: 1.46 kB
  
  &lt;!DOCTYPE html&gt;
  &lt;html lang=&quot;en&quot;&gt;
  &lt;head&gt;
    &lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;
    &lt;meta name=&quot;robots&quot; content=&quot;NONE,NOARCHIVE&quot;&gt;
    &lt;title&gt;403 Forbidden&lt;/title&gt;
    &lt;style type=&quot;text/css&quot;&gt;
      html * { padding:0; margin:0; }
      body * { padding:10px 20px; }
  </code></pre>