c# - Azure 存储表插入失败并显示 "One of the request inputs is not valid"

标签 c# azure azure-table-storage

我正在尝试使用 Insert Entity API 将哑实体插入 JavaScript 中的 Azure 存储表中。我启用了 CORS 并设法对我的请求进行身份验证,但我的简单请求失败,并显示 其中一个请求输入无效。 消息

以下是有关请求的更多详细信息:

Accept:application/json;odata=nometadata
Accept-Encoding:gzip, deflate
Accept-Language:en-US,en;q=0.8
Authorization:SharedKey <account>:<secret>
Cache-Control:no-cache
Connection:keep-alive
Content-Length:70
Content-type:application/json
DataServiceVersion:3.0;NetFx
Host:<account>.table.core.windows.net
If-Match:*
MaxDataServiceVersion:3.0;NetFx
Origin:http://localhost:6091
Referer:http://localhost:6091/
x-ms-date:Fri, 08 Jan 2016 06:23:29 GMT
x-ms-version:2013-08-15

这是请求负载:

{Message: "test", RowKey: "myrowkey", PartitionKey: "mypartitionkey"}

这是响应,其 HTTP 状态为 400:

Access-Control-Allow-Origin:*
Access-Control-Expose-Headers:x-ms-request-id,x-ms-version
Content-Type:application/json;odata=nometadata;streaming=true;charset=utf-8
Date:Fri, 08 Jan 2016 06:23:30 GMT
Server:Windows-Azure-Table/1.0 Microsoft-HTTPAPI/2.0
Transfer-Encoding:chunked
X-Content-Type-Options:nosniff
x-ms-request-id:4994f291-0002-004d-1cdd-49d7ff000000
x-ms-version:2013-08-15

有一个 body :

{"odata.error":{"code":"InvalidInput","message":{"lang":"en-US","value":"One of the request inputs is not valid.\nRequestId:4994f291-0002-004d-1cdd-49d7ff000000\nTime:2016-01-08T06:23:30.4716844Z"}}}

我看到有人提示这个非描述性错误消息。不过,我很确定这个请求负载没问题。 RowKeyPartitionKey 没有特殊字符,并且 Message 字段不必提供其 odata 类型(但相信我,我也尝试过)。我也尝试了作为示例提供的有效负载,但问题仍然存在。

最佳答案

我通过反复试验的方法找到了解决方案。请求 header If-Match:* 是问题所在。我删除了该 header ,它开始工作。

Azure 肯定需要更明确、更清晰地了解其文档和错误消息。

关于c# - Azure 存储表插入失败并显示 "One of the request inputs is not valid",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34670853/

相关文章:

c# - 无法声明 ArrayList

azure - Azure 是否提供类似 pubnub 和 Pusher 的服务?

sql-server - 如何高效存储和查询十亿行传感器数据

python - Azure 存储表返回空实体

c# - 在 Visual Studio 2019 中构建 C# 函数应用程序时获取 "Metadata generation failed"

表存储上的 Azure 函数 CRUD

C# 嵌套列表存储不正确的值

c# - ASP.NET C# Ajax 调用错误

c# - 连接事件处理器

azure - 使用模板在现有资源组中创建 Azure 容器注册表