Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot access azure storage table using SAS via c#. Works in postman and browser

I am trying to obtain and parse a table from azure storage.

I generated a Shared Access Signature in azure storage explorer.

If I paste the generated url into browser or postman I get the table back as xml.

However, trying to do a HttpWebRequest with the url results in

System.Net.WebException: 'The remote server returned an error: (415) Unsupported Media Type.'

I have tried different content and accept types

const string url = @"https://laptopdeploymentfiles.table.core.windows.net/PaulLoginScript?st=2019-08-21T08%3A10%3A22Z&se=2019-08-22T08%3A10%3A22Z&sp=r&sv=2018-03-28&tn=paulloginscript&sig=***";

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);

request.Method = "GET";

var webResponse = request.GetResponse();

I have tried both

request.Accept = "application/xml";

and

 request.ContentType = "application/xml";

but still get the same error.

I have also tried creating and accessing a new table with only simple data. The data accessed via the brower is valid xml, but I still get the same error from a c# app.

The solution was to use both the following contenttype and accept formats

  request.Accept = "application/json";
     request.ContentType = "application/json";
like image 473
Paul Prichard Avatar asked Nov 05 '25 20:11

Paul Prichard


1 Answers

The solution was to use both the following contenttype and accept formats

request.Accept = "application/json";
request.ContentType = "application/json";
like image 169
Paul Prichard Avatar answered Nov 08 '25 12:11

Paul Prichard



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!