title: Blob Service REST API - Put Blob returning 403 Forbidden when x-ms-blob-content-type is set
body: <p>I've successfully been able to create Blobs in my container, but when I try to set the x-ms-blob-content-type header, no Blob is created and I get a 403 error. Here is my code:</p>
  
  <pre><code>    var authorizationHeader = CreateAuthorizationHeader(stringToSign);
  
      HttpWebRequest request = (HttpWebRequest)WebRequest.Create(blobEndpoint + urlPath);
      request.Method = requestMethod;
      request.Headers["x-ms-blob-type"] = blobType;            
      request.Headers["x-ms-date"] = dateInRfc1123Format;
      request.Headers["x-ms-version"] = storageServiceVersion;
      request.Headers["Authorization"] = authorizationHeader;
      request.ContentLength = blobLength;            
  
      try
      {
          using (Stream requestStream = await request.GetRequestStreamAsync())
          {
              requestStream.Write(blobContent, 0, blobLength);
          }
  
          using(HttpWebResponse response = (HttpWebResponse)await request.GetResponseAsync())
          {
              var eTag = response.Headers["ETag"];
          }
      }
  </code></pre>
  
  <p>But whenever I try to add either of these lines, I get a 403:</p>
  
  <pre><code>request.Headers["x-ms-blob-content-type"] = "image/jpeg";
  //or
  request.ContentType = "image/jpeg";
  </code></pre>
  
  <p>Have any of you encountered this? Appreciate any feedback, thanks!</p>
  
  <p><strong>UPDATE:</strong> adding the stringToSign code below.</p>
  
  <pre><code>var canonicalizedHeaders = String.Format(
      "x-ms-blob-type:{0}\nx-ms-date:{1}\nx-ms-version:{2}",
      blobType,
      dateInRfc1123Format,
      storageServiceVersion);
  var canonicalizedResource = String.Format("/{0}/{1}", account, urlPath);
  var stringToSign = String.Format(
      "{0}\n\n\n{1}\n\n\n\n\n\n\n\n\n{2}\n{3}",
      requestMethod,
      blobLength,
      canonicalizedHeaders,
      canonicalizedResource);
  </code></pre>