JSON format Not supported exception from Azure storage REST API

☆樱花仙子☆ 提交于 2019-12-24 21:48:19

问题


I am working on REST API calls on Azure storage table, I am successful to query table and get response in xml format but when I try to change the Accept header to JSON I am getting the exceptions.

Note: I set the value of x-ms-version to 2018-03-28

    headers.put("Authorization", "SharedKey " + store + ":" + hash);
    headers.put("x-ms-date", date);
//        headers.put("x-ms-version","2009-09-19");
    headers.put("x-ms-version","2018-03-28");
    headers.put("Accept-Charset","UTF-8");
//        headers.put("Accept","application/atom+xml,application/xml");
    headers.put("Accept","application/json;odata=nometadata");
    headers.put("DataServiceVersion","1.0;NetFx");
    headers.put("MaxDataServiceVersion","1.0;NetFx");

I am getting the Response status code 415 with message "JsonFormatNotSupportedJSON format is not supported."


回答1:


DataServiceVersion and MaxDataServiceVersion are not necessary, but if you want to use, change them to 3.0;NetFx.

Only 3.0 is compatible with x-ms-version 2013-08-15 or later. See the document.




回答2:


I have removed below 2 headers and now I am getting the response in JSON format.

    headers.put("DataServiceVersion","1.0;NetFx");
    headers.put("MaxDataServiceVersion","1.0;NetFx");


来源:https://stackoverflow.com/questions/51148537/json-format-not-supported-exception-from-azure-storage-rest-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!