title: 401 Unauthorized on Adyen API
body: <p>I'm trying to do a payment in my test environment in Adyen with curl but for some reason I keep getting a 401 Unauthorized response back. I have checked the credentials of the Web Service User a dozen times but I'm sure they are correct. When I try the official Adyen PHP Api library (<a href="https://github.com/Adyen/adyen-php-api-library" rel="nofollow noreferrer">https://github.com/Adyen/adyen-php-api-library</a>) I get the same results. I have also tried creating a new Web Service User but without results. Has anyone an idea what I'm doing wrong?</p>
  
  <p><strong>The request code:</strong></p>
  
  <pre><code>&lt;?php
  
  $request = array(
      "merchantAccount" =&gt; "MyWebsite",
      "amount" =&gt; array(
          "currency" =&gt; "EUR",
          "value" =&gt; "199"
      ),
      "reference" =&gt; "TEST-PAYMENT-" . date("Y-m-d-H:i:s"),
      "shopperIP" =&gt; "2.207.255.255",
      "shopperReference" =&gt; "YourReference",
      "billingAddress" =&gt; array(
          "street" =&gt; "Simon Carmiggeltstraat",
          "postalCode" =&gt; "1011DJ",
          "city" =&gt; "Amsterdam",
          "houseNumberOrName" =&gt; "6-60",
          "stateOrProvince" =&gt; "NH",
          "country" =&gt; "NL"
      ),
      "card" =&gt; array(
          "expiryMonth" =&gt; "08",
          "expiryYear" =&gt; "2018",
          "holderName" =&gt; "Test Card Holder",
          "number" =&gt; "4111111111111111",
          "cvc" =&gt; "737"
      ),
  );
  
  $json = json_encode($request);
  
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, "https://pal-test.adyen.com/pal/servlet/Payment/v25/authorise");
  curl_setopt($ch, CURLOPT_HEADER, false);
  curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC  );
  curl_setopt($ch, CURLOPT_USERPWD, "xxxx:xxxx");
  curl_setopt($ch, CURLOPT_POST, count($request));
  curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_HTTPHEADER,array("Content-type: application/json"));
  
  // things I tried
  curl_setopt($ch, CURLOPT_USERAGENT,'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.52 Safari/537.17');
  curl_setopt($ch, CURLOPT_AUTOREFERER, true);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  curl_setopt($ch, CURLOPT_VERBOSE, 1);
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
  curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
  
  $result = curl_exec($ch);
  
  ?&gt;
  </code></pre>
  
  <p>The $result variable returns an empty string.</p>
  
  <p><strong>Response:</strong></p>
  
  <pre><code>*   Trying 91.212.42.153...
  * Connected to pal-test.adyen.com (91.212.42.153) port 443 (#0)
  * ALPN, offering http/1.1
  * Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
  * successfully set certificate verify locations:
  *   CAfile: /etc/ssl/certs/ca-certificates.crt
    CApath: /etc/ssl/certs
  * SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
  * ALPN, server did not agree to a protocol
  * Server certificate:
  *    subject: C=NL; ST=Noord-Holland; L=Amsterdam; O=Adyen B.V.; CN=*.adyen.com
  *    start date: Jun 14 00:00:00 2016 GMT
  *    expire date: Aug 13 23:59:59 2018 GMT
  *    issuer: C=US; O=thawte, Inc.; CN=thawte SSL CA - G2
  *    SSL certificate verify ok.
  * Server auth using Basic with user 'xxxxx'
  &gt; POST /pal/servlet/Payment/v25/authorise HTTP/1.1
  Host: pal-test.adyen.com
  Authorization: Basic xxxxxx
  User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.52 Safari/537.17
  Accept: */*
  Content-type: application/json
  Content-Length: 465
  
  * upload completely sent off: 465 out of 465 bytes
  &lt; HTTP/1.1 401 Unauthorized
  &lt; Date: Mon, 02 Apr 2018 19:58:11 GMT
  &lt; Server: Apache
  &lt; Set-Cookie: JSESSIONID=47E667BF9B585DC3BDF40F8D58493E23.test103e; Path=/pal; Secure; HttpOnly
  * Authentication problem. Ignoring this.
  &lt; WWW-Authenticate: BASIC realm="Adyen PAL Service Authentication"
  &lt; Content-Length: 0
  &lt; Content-Type: text/plain; charset=UTF-8
  &lt; 
  * Connection #0 to host pal-test.adyen.com left intact
  </code></pre>