Getting 500 Internal Server error on sending the token and requesting SAS URI
<p>I am passing token as :</p>

<pre><code>    String access_token = object.get("access_token").toString();
    System.out.println("Access Token --------&gt;" + access_token);
    System.out.println("Decoded Access Token --------&gt; " +URLDecoder.decode(access_token));
    //String basicAuth = "Basic "+ new String(new Base64().encode(access_token.getBytes()));
    CreateSubmissionMetadata(access_token);

public static void CreateSubmissionMetadata (String access_token) throws ClientProtocolException, IOException{

        HttpClient httpClient = HttpClientBuilder.create().build();
        String sysdevEndPoint = "https://devicesigningservice.cloudapp.net/api/signing/devices";
        HttpPost request = new HttpPost(sysdevEndPoint);
        StringEntity params =new StringEntity("{\"TestHarnessType\": \"HLK\",\"OSSelections\": [{\"OS\",\"Windows 7\"},{\"OS\",\"Windows 8\"},{\"OS\",\"Windows 8.1\"},{\"OS\",\"Windows 10\"}],\"ProductName\":\"Test Name\",\"InitialUploadFileSize\": &lt;size&gt;}");
        request.setHeader("Content-Type", "application/json");
        System.out.println("Sending token ----&gt;"+ access_token);
        request.setHeader("Authorization: Bearer ", access_token);
        Log.d("DEBUG", "HEADERS: " + request.getFirstHeader("Authorization: Bearer"));
        request.setEntity(params);
        System.out.println("sending Request--------------------------------------------------------------------------&gt;");
        HttpResponse response = httpClient.execute(request);
        System.out.println("-------------------------------------------------------------------------------------------------------");
        System.out.println(response);
        System.out.println("-------------------------------------------------------------------------------------------------------");
        Header[] headers = response.getAllHeaders();
        for (Header header : headers) {
            System.out.println("Key : " + header.getName() 
            + " ,Value : " + header.getValue());
        }
</code></pre>

<p>I got access_token from Access control server and I am trying to use that and get SAS URI but while passing the token in header I am getting HTTP response code as 500.(I missed the trailing "/" in scope while generating token thats why I was getting 401 error)</p>

<p>API document: <a href="https://msdn.microsoft.com/en-us/library/windows/hardware/dn800660(v=vs.85).aspx" rel="nofollow">https://msdn.microsoft.com/en-us/library/windows/hardware/dn800660(v=vs.85).aspx</a></p>

<p>output:</p>

<pre><code>HttpResponseProxy{HTTP/1.1 401 Unauthorized [Content-Type: text/html, Server:Microsoft-IIS/8.5, X-Powered-By: ASP.NET, Date: Tue, 05 Jul 2016 19:36:02 GMT,
Content-Length: 1293] ResponseEntityProxy{[Content-Type: text/html,Content-
Length: 1293,Chunked: false]}}
Key : Content-Type ,Value : text/html
Key : Server ,Value : Microsoft-IIS/8.5
Key : X-Powered-By ,Value : ASP.NET
Key : Date ,Value : Tue, 05 Jul 2016 19:36:02 GMT
Key : Content-Length ,Value : 1293
</code></pre>

<p>Enabling log:</p>

<pre><code>2016/07/05 16:27:40:237 EDT [DEBUG] RequestAddCookies - CookieSpec selected: default
2016/07/05 16:27:40:237 EDT [DEBUG] RequestAuthCache - Auth cache not set in the context
2016/07/05 16:27:40:238 EDT [DEBUG] PoolingHttpClientConnectionManager - Connection request: [route: {s}-&gt;https://devicesigningservice.cloudapp.net:443][total kept alive: 0; route allocated: 0 of 2; total allocated: 0 of 20]
2016/07/05 16:27:40:238 EDT [DEBUG] PoolingHttpClientConnectionManager - Connection leased: [id: 1][route: {s}-&gt;https://devicesigningservice.cloudapp.net:443][total kept alive: 0; route allocated: 1 of 2; total allocated: 1 of 20]
2016/07/05 16:27:40:238 EDT [DEBUG] MainClientExec - Opening connection {s}-&gt;https://devicesigningservice.cloudapp.net:443
2016/07/05 16:27:40:240 EDT [DEBUG] DefaultHttpClientConnectionOperator - Connecting to devicesigningservice.cloudapp.net/191.246.47.593:843
2016/07/05 16:27:40:240 EDT [DEBUG] SSLConnectionSocketFactory - Connecting socket to devicesigningservice.cloudapp.net/191.246.47.593:843 with timeout 0
2016/07/05 16:27:40:256 EDT [DEBUG] SSLConnectionSocketFactory - Enabled protocols: [TLSv1, TLSv1.1, TLSv1.2]
2016/07/05 16:27:40:256 EDT [DEBUG] SSLConnectionSocketFactory - Enabled cipher suites:[TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256, TLS_RSA_WITH_AES_128_CBC_SHA256, TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256, TLS_DHE_RSA_WITH_AES_128_CBC_SHA256, TLS_DHE_DSS_WITH_AES_128_CBC_SHA256, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDH_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_DSS_WITH_AES_128_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_DSS_WITH_AES_128_GCM_SHA256, TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA, TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA, SSL_RSA_WITH_3DES_EDE_CBC_SHA, TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA, TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA, SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA, SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA, TLS_EMPTY_RENEGOTIATION_INFO_SCSV]
2016/07/05 16:27:40:256 EDT [DEBUG] SSLConnectionSocketFactory - Starting handshake
2016/07/05 16:27:40:517 EDT [DEBUG] SSLConnectionSocketFactory - Secure session established
2016/07/05 16:27:40:517 EDT [DEBUG] SSLConnectionSocketFactory -  negotiated protocol: TLSv1.2
2016/07/05 16:27:40:517 EDT [DEBUG] SSLConnectionSocketFactory -  negotiated cipher suite: TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256
2016/07/05 16:27:40:517 EDT [DEBUG] SSLConnectionSocketFactory -  peer principal: CN=devicesigningservice.cloudapp.net
2016/07/05 16:27:40:517 EDT [DEBUG] SSLConnectionSocketFactory -  peer alternative names: [devicesigningservice.cloudapp.net]
2016/07/05 16:27:40:517 EDT [DEBUG] SSLConnectionSocketFactory -  issuer principal: CN=Microsoft IT SSL SHA2, OU=Microsoft IT, O=Microsoft Corporation, L=Redmond, ST=Washington, C=US
2016/07/05 16:27:40:518 EDT [DEBUG] DefaultHttpClientConnectionOperator - Connection established 9.82.117.101:65081&lt;-&gt;191.246.47.593:843
2016/07/05 16:27:40:518 EDT [DEBUG] MainClientExec - Executing request POST /api/signing/devices HTTP/1.1
2016/07/05 16:27:40:518 EDT [DEBUG] MainClientExec - Proxy auth state: UNCHALLENGED
2016/07/05 16:27:40:518 EDT [DEBUG] headers - http-outgoing-1 &gt;&gt; POST /api/signing/devices HTTP/1.1
2016/07/05 16:27:40:518 EDT [DEBUG] headers - http-outgoing-1 &gt;&gt; Content-Type: application/json
2016/07/05 16:27:40:518 EDT [DEBUG] headers - http-outgoing-1 &gt;&gt; Authorization: Bearer http%3a%2f%2fschemas.microsoft.com%blah%bla
2016/07/05 16:27:40:518 EDT [DEBUG] headers - http-outgoing-1 &gt;&gt; Content-Length: 181
2016/07/05 16:27:40:518 EDT [DEBUG] headers - http-outgoing-1 &gt;&gt; Host: devicesigningservice.cloudapp.net
2016/07/05 16:27:40:519 EDT [DEBUG] headers - http-outgoing-1 &gt;&gt; Connection: Keep-Alive
2016/07/05 16:27:40:519 EDT [DEBUG] headers - http-outgoing-1 &gt;&gt; User-Agent: Apache-HttpClient/4.5.2 (Java/1.8.0_77)
2016/07/05 16:27:40:519 EDT [DEBUG] headers - http-outgoing-1 &gt;&gt; Accept-Encoding: gzip,deflate
2016/07/06 15:14:19:022 EDT [DEBUG] headers - http-outgoing-1 &lt;&lt; HTTP/1.1 500 Internal Server Error
2016/07/06 15:14:19:022 EDT [DEBUG] headers - http-outgoing-1 &lt;&lt; Cache-Control: no-cache
2016/07/06 15:14:19:022 EDT [DEBUG] headers - http-outgoing-1 &lt;&lt; Pragma: no-cache
2016/07/06 15:14:19:022 EDT [DEBUG] headers - http-outgoing-1 &lt;&lt; Content-Type: application/json; charset=utf-8
2016/07/06 15:14:19:022 EDT [DEBUG] headers - http-outgoing-1 &lt;&lt; Expires: -1
2016/07/06 15:14:19:023 EDT [DEBUG] headers - http-outgoing-1 &lt;&lt; Server: Microsoft-IIS/8.5
2016/07/06 15:14:19:023 EDT [DEBUG] headers - http-outgoing-1 &lt;&lt; X-AspNet-Version: 4.0.30319
2016/07/06 15:14:19:023 EDT [DEBUG] headers - http-outgoing-1 &lt;&lt; X-Powered-By: ASP.NET
2016/07/06 15:14:19:023 EDT [DEBUG] headers - http-outgoing-1 &lt;&lt; Date: Wed, 06 Jul 2016 19:14:18 GMT
2016/07/06 15:14:19:023 EDT [DEBUG] headers - http-outgoing-1 &lt;&lt; Content-Length: 36
2016/07/06 15:14:19:023 EDT [DEBUG] MainClientExec - Connection can be kept alive indefinitely
</code></pre>