1

I'm trying to request a line from Azure Table Storage using the REST API and C++, but always got the following error:

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
  <cod_e>JsonFormatNotSupported</cod_e>
  <message xml:lang="en-US">JSON format is not supported.
RequestId:0ccb3b9b-0002-0029-3389-0d2fa1000000
Time:2016-09-13T06:39:13.3155742Z</message>
</error>

Here is my request:

GET https://<myaccount>.table.core.windows.net/<mytable>(PartitionKey='<mypartition>',RowKey='<myrow>')?<sharedsignature>

Here how I fill request headers, as from https://msdn.microsoft.com/en-us/library/dd179428.aspx:

std::string sharedAccessSignature("<sharedsignature>");
std::string dateTime(GetDateTime());
std::string stringToSign(dateTime + "\n/" + account + "/" + "<mytable>");
std::string request("(PartitionKey='<mypartition>',RowKey='<myrow>')");
stringToSign += request;
std::string signatureString(HMACSHA256(stringToSign, sharedAccessSignature));

headers["Authorization"] = "SharedKeyLite " + account + ":" + signatureString;
headers["DataServiceVersion"] = "3.0;NetFx";
headers["MaxDataServiceVersion"] = "3.0;NetFx";
headers["x-ms-version"] = "2015-12-11";
headers["x-ms-date"] = dateTime;
headers["Accept"] = "application/json;odata=verbose";
headers["Accept-Charset"] = "UTF-8";

The table exists and is not empty.
Please advise what's wrong?

Update 1
Removing sharedsignature from request, i.e. GET https://<myaccount>.table.core.windows.net/<mytable>(PartitionKey='<mypartition>',RowKey='<myrow>') leads to the same result.
Removing Authorization header from the request leads to the same result too.

Update 2
Putting https://<myaccount>.table.core.windows.net/<mytable>(PartitionKey='<mypartition>',RowKey='<myrow>')?<sharedsignature> in a browser produces a valid response, but in Atom format.

<?xml version="1.0" encoding="utf-8"?>
<entry 
  xml:base="https://<myaccount>.table.core.windows.net/" 
  xmlns="http://www.w3.org/2005/Atom" 
  xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" 
  xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" 
  m:etag="W/&quot;datetime'2016-09-13T05%3A29%3A51.211538Z'&quot;">
  <id>https://<myaccount>.table.core.windows.net/<mytable> (PartitionKey='<mypartition>',RowKey='<myrow>')</id>
  <category term="<myaccount>.<mytable>" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
  <link rel="edit" title="<mytable>" href="<mytable> (PartitionKey='<mypartition>',RowKey='<myrow>')" />
  <title />
  <updated>2016-09-13T11:25:19Z</updated>
  <author><name /></author>
  <content type="application/xml">
    <m:properties>
      <d:PartitionKey><mypartition></d:PartitionKey>
      <d:RowKey><myrow></d:RowKey>
      <d:Timestamp m:type="Edm.DateTime">2016-09-13T05:29:51.211538Z</d:Timestamp>
      <d:Score m:type="Edm.Int32">1050</d:Score>
    </m:properties>
  </content>
</entry>

Update 3
Investigation situation using curl I found that adding Accept: application/json;odata=fullmetadata to the request headers leads to the error above. Default Accept */* in headers produces valid Atom response.

7
  • 2
    Instead of this headers["Accept"] = "application/json;odata=verbose";, please use headers["Accept"] = "application/json;odata=fullmetadata";. Also, I am not sure why are you appending <sharedsignature>? I don't think it is needed. Commented Sep 13, 2016 at 7:05
  • @GauravMantri: Changing Accept header as you proposed leads to the same result. When I remove ?<sharedsignature> part from GET request I got ResourceNotFound error: The specified resource does not exist. Commented Sep 13, 2016 at 7:16
  • 1
    What's this sharedAccessSignature in your code? Is it SAS Token? Please note that if you're using Shared Access Signature, you need not calculate/define Authorization header as the authorization information is included in your SAS token itself (sig). Commented Sep 13, 2016 at 7:21
  • @GauravMantri Yes, this is SAS token. But without Authorization header situation is the same. Commented Sep 13, 2016 at 8:47
  • 1
    But without Authorization header situation is the same -> This is weird. Would you mind updating your question after all the changes you have done so that we can see what's going on with your code. Commented Sep 13, 2016 at 9:10

1 Answer 1

5

Finally, got it!
The issue was in my shared signature.
While looking at it I found sv=2012-02-12 part, and assumed, that it means API version. The version, before JSON support was introduced! I created a new shared signature and finally got JSON with the following curl command.
curl -v -H "Accept: application/json;odata=nometadata" -H "x-ms-version: 2015-12-11" "https://<myaccount>.table.core.windows.net/<mytable>(PartitionKey='<mypartition>',RowKey='<myrow>')?<mysharedsignature>"

So, for everyone, who face the same issue in the future: please check your signature first!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.