title: HTTPError: Bad Request for Python urllib
body: <p>This is my first project using API/python. Basically, I want to get information from trackhive.com to see where is the package. But first, to understand how it works, I'm just trying to create a track.</p>
  <p>On the website, they give me this example:</p>
  <pre><code>from urllib2 import Request, urlopen
  
  values = &quot;&quot;&quot;
    {
      &quot;tracking_number&quot;: &quot;9361289676090919095393&quot;,
      &quot;slug&quot;: &quot;usps&quot;
    }
  &quot;&quot;&quot;
  
  headers = {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer Token'
  }
  request = Request('https://private-anon-6175dd5596-trackhive.apiary-proxy.com/trackings
  ', data=values, headers=headers)
  
  response_body = urlopen(request).read()
  </code></pre>
  <p>As I'm using Python 3, my code is</p>
  <pre><code>import json
  import urllib.request
  
  values = &quot;&quot;&quot;
    {
      &quot;tracking_number&quot;: &quot;9361289676090919095393&quot;,
      &quot;slug&quot;: &quot;usps&quot;
    }
  &quot;&quot;&quot;
  
  headers = {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer mytokenAPI'
  }
  
  url = 'https://private-anon-6175dd5596-trackhive.apiary-proxy.com/trackings'
  request = urllib.request.Request(url,data=values, headers=headers)
  
  response_body = urllib.request.urlopen(request, data=bytes(json.dumps(headers), encoding=&quot;utf-8&quot;)).read()
  </code></pre>
  <p>But when it calls the &quot;urllib.request.urlopen&quot;, it returns &quot;HTTPError: Bad Request&quot;. What am I doing wrong?</p>
  <p>On the website, they said that the endpoint is located at: <a href="https://api.trackinghive.com" rel="nofollow noreferrer">https://api.trackinghive.com</a>. In their code, they are accessing: 'https://private-anon-6175dd5596-trackhive.apiary-proxy.com/trackings'. If I haven't access to their example, how could I know that I suppose to access this URL, and not something like &quot;https://api.trackinghive.com/trackings&quot;? Isn't it suppose to use the endpoint somewhere?</p>
  <p>(I'm sorry about all these questions, I'm a little confused about how these codes with API and URL works)</p>
  <p>I appreciate any help ^^</p>
  <p>Edit:</p>
  <p>Link to documentation:
  <a href="https://trackhive.docs.apiary.io/#introduction/api-requirements/end-point" rel="nofollow noreferrer">https://trackhive.docs.apiary.io/#introduction/api-requirements/end-point</a></p>