title: idHTTP.Post Error HTTP/1.1 401
body: <p>I am trying to access the idHTTP Delphi in a json server without success. I've tried all the alternatives and always got the same error: "HTTP / 1.1 401 Unauthorized".</p>
  
  <p>JSON format for testing: </p>
  
  <blockquote>
    <p>{"http":{"method":"POST","header":"access_token:55b3ce85b47629eeee778c0f0c9be450f1b1bc84cc377975f2d3d0d3808a4636", "content":"name=TEST&amp;email=teste@uol.com&amp;phone=1147001211&amp;mobilePhone=11992329909&amp;address=Rua+Jose+Ricardo &amp;addressNumber=55&amp;province=Test&amp;notificationDisabled=True&amp;city=Sao+Paulo&amp;state=SP&amp;country=Brasil&amp;postalCode=05567210 &amp;cpfCnpj=11111111111&amp;personType=FISICA"}}</p>
  </blockquote>
  
  <p>Url for testing:</p>
  
  <blockquote>
    <p><a href="http://homolog.asaas.com/api/v2/customers" rel="nofollow">http://homolog.asaas.com/api/v2/customers</a></p>
  </blockquote>
  
  <p>Procedure for testing:</p>
  
  <pre><code>procedure TForm4.Button2Click(Sender: TObject);
  var
   sResponse: string;
   EnvStr : TStringList;
  begin
   EnvStr := TStringList.Create;
   EnvStr.AddStrings(Memo.Lines);
   try
    idHTTP.Request.ContentType := 'application/json';
    idHTTP.Request.Method:='POST';
    idHTTP.Request.AcceptCharSet := 'utf-8';
    try
     sResponse := idHTTP.Post(EditURL.Text,EnvStr);
    except
     on E: Exception do
      ShowMessage('Error on request: '#13#10 + e.Message);
    end;
   finally
    MemoRet.Lines.Clear;
    MemoRet.Lines.add(sResponse);
   end;
  end;
  </code></pre>
  
  <p>The same format sent in PHP works perfectly, but with idHTTP returns the error: "HTTP / 1.1 401 Unauthorized".</p>
  
  <p>PHP works perfectly</p>
  
  <pre><code>&lt;?php
   $api_url = "http://homolog.asaas.com/api/v2";   
   $api_key = "55b3ce85b47629eeee778c0f0c9be450f1b1bc84cc377975f2d3d0d3808a4636";
   $url_cus = $api_url."/customers";
   $param = array(
  'name' =&gt; utf8_encode('Test'),
  'email' =&gt; 'test@uol.com.br',
  'phone' =&gt; '1147001211',
  'mobilePhone' =&gt; '11992329909',
  'address' =&gt; utf8_encode('Rua Jose Ricardo'),
  'addressNumber' =&gt; '55',
  'province' =&gt; 'Test',
  'notificationDisabled' =&gt; 'True',
  'city' =&gt; 'Sao Paulo',
  'state' =&gt;'SP',
  'country' =&gt; 'Brasil',
  'postalCode' =&gt; '05567210',
  'cpfCnpj' =&gt; '11111111111',
  'personType' =&gt; 'FISICA'
    );
   $req = http_build_query($param);
   $ctx = stream_context_create(
   array(
         "http" =&gt; array(
         "method" =&gt; "POST",
         "header" =&gt; "access_token: $api_key",
         "content" =&gt; $req
          )
        )
       );
  
   $res = file_get_contents($url_cus, true, $ctx);
  
   //PHP Object
   $obj = json_decode($res);
  
   //get id of register 
   $id=utf8_decode("$obj-&gt;id");
  
   // return result
   // return $id;
  
  ?&gt;
  </code></pre>