microsoft / Dynamics-AX-Integration

Dynamics AX Integration samples and demos.
285 stars 356 forks source link

Upload package: Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature #96

Open h3david opened 4 years ago

h3david commented 4 years ago

Hi,

Based on this sample:

Dynamics-AX-Integration\FileBasedIntegrationSamples\ConsoleAppSamples\DataPackageHandler

and using freshly requested upload url, I'm falling to upload a zip file using the following snippet:

 var url = @"https://myInstanceNameAWierdToken.core.windows.net/dmf/file.zip?sv=2014-02-14&sr=b&sig=tOx6JpfgQHzPLGmdiyAY%2B0QgJj%2BzjjJ8sFClzteZtcM%3D&st=2019-08-16T20%3A09%3A42Z&se=2019-08-16T20%3A44%3A42Z&sp=rw\";

            var urlDecode = HttpUtility.UrlDecode(url);

            using (FileStream stream = new FileStream(@"C:\Users\usera\file.zip", FileMode.Open))
            {
                var blob = new CloudBlockBlob(new Uri(url));
                //var blob = new CloudBlockBlob(new Uri(urlDecode));
                blob.UploadFromStream(stream);
            }

As you can see I tried with and without an decoded url to get rid of the html encoded characters

Here are the details of the exception that I get:

Microsoft.Azure.Storage.StorageException HResult=0x80131500 Message=Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature. Source=Microsoft.Azure.Storage.Common StackTrace: at Microsoft.Azure.Storage.Core.Executor.Executor.d1`1.MoveNext() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Azure.Storage.Core.Executor.Executor.<>cDisplayClass0_01.<ExecuteSync>b__0() at Microsoft.Azure.Storage.Core.Util.CommonUtility.RunWithoutSynchronizationContext[T](Func1 actionToRun) at Microsoft.Azure.Storage.Core.Executor.Executor.ExecuteSync[T](RESTCommand1 cmd, IRetryPolicy policy, OperationContext operationContext) at Microsoft.Azure.Storage.Blob.CloudBlockBlob.UploadFromStreamHelper(Stream source, Nullable1 length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) at Microsoft.Azure.Storage.Blob.CloudBlockBlob.UploadFromStream(Stream source, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) at KeyDecoder.Program.Main(String[] args) in C:\Users\helod\source\justSomeTests\KeyDecoder\Program.cs:line 24

Am I missing something ?

Thanks in advance.