Azure Table Service REST API: JSON format is not supported -
i'm trying request line azure table storage using rest api , c++, got 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 not supported. requestid:0ccb3b9b-0002-0029-3389-0d2fa1000000 time:2016-09-13t06:39:13.3155742z</message> </error>
here request:
get https://<myaccount>.table.core.windows.net/<mytable>(partitionkey='<mypartition>',rowkey='<myrow>')?<sharedsignature>
here how fill request headers, 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 , not empty.
please advise what's wrong?
update 1
removing sharedsignature
request, i.e. get https://<myaccount>.table.core.windows.net/<mytable>(partitionkey='<mypartition>',rowkey='<myrow>')
leads same result.
removing authorization
header request leads same result too.
update 2
putting https://<myaccount>.table.core.windows.net/<mytable>(partitionkey='<mypartition>',rowkey='<myrow>')?<sharedsignature>
in browser produces valid response, 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/"datetime'2016-09-13t05%3a29%3a51.211538z'""> <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
found adding accept: application/json;odata=fullmetadata
request headers leads error above. default accept */*
in headers produces valid atom response.
finally, got it!
issue in shared signature.
while looking @ found sv=2012-02-12
part, , assumed, means api version. version, before json support introduced! created new shared signature , got json 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, everyone, face same issue in future: please check signature first!
Comments
Post a Comment