title: Implementing Put Block of Azure rest api?
body: <p>I am following this MSDN Reference (<a href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/put-block" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/put-block</a>) to implement a rest call for Put Block.</p>
  
  <p>I am coding in Java and I formed below Authorisation string and URL before signing.</p>
  
  <pre><code>PUT
  
  
  364070
  
  
  
  
  
  
  
  
  x-ms-blob-type:BlockBlob
  x-ms-date:Fri, 20 Jan 2017 12:57:06 GMT
  x-ms-version:2016-05-31
  /xyz/mycontainer/imageBlock1
  comp:block
  sun.net.www.protocol.https.DelegateHttpsURLConnection:https://xyz.blob.core.windows.net/mycontainer/imageBlock1?comp=block&amp;blockid=YmxvY2stMQ==
  
  Error I am getting:
  403
      Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.
  </code></pre>
  
  <p>I read gaurav mantras post <a href="http://gauravmantri.com/2013/02/16/uploading-large-files-in-windows-azure-blob-storage-using-shared-access-signature-html-and-javascript/" rel="nofollow noreferrer">http://gauravmantri.com/2013/02/16/uploading-large-files-in-windows-azure-blob-storage-using-shared-access-signature-html-and-javascript/</a>. But, its not working for me.</p>
  
  <blockquote>
    <p>Is there anything wrong with the string I am sending to sign or URL or
    below httpConn Request Header.</p>
  </blockquote>
  
  <p>The Http Header I am setting is:</p>
  
  <pre><code>httpConn.setRequestMethod("PUT");
                  httpConn.setRequestProperty("x-ms-blob-type", blobType);
                  httpConn.setRequestProperty("x-ms-date", date);
                  httpConn.setRequestProperty("x-ms-version", storageServiceVersion);
                  httpConn.setRequestProperty("Authorization", authorizationHeader);
                  httpConn.setRequestProperty("Content-Length",String.valueOf(blobLength) );
  
                  System.out.println(httpConn);
  
                  DataOutputStream wr = new DataOutputStream(httpConn.getOutputStream());
                  wr.write(bytes);
                  wr.flush();
                  wr.close();
                  int response = httpConn.getResponseCode();
  </code></pre>