表存储上的 azure REST 实体组事务上的 InvalidInput

Posted

技术标签:

【中文标题】表存储上的 azure REST 实体组事务上的 InvalidInput【英文标题】:InvalidInput on azure REST entity group transaction on table storage 【发布时间】:2022-01-12 02:15:34 【问题描述】:

我不知道在这里做什么。根据文档 https://docs.microsoft.com/en-us/rest/api/storageservices/performing-entity-group-transactions

我发送一个帖子请求到

var url = 'https://$myaccount.table.core.windows.net/\$batch?sv=($sasToken)'

标题:

   var headers = 
      "x-ms-date": "2021-12-06 22:12:15.862319Z"
      "Accept-Charset": "UTF-8"
      "x-ms-version": "2020-10-02"
      "content-type": "multipart/mixed; boundary=batch_8360b73e-53ce-4ab8-8de8-3894086bd694"
      "Connection": "Keep-Alive"
      "DataServiceVersion": "3.0"
      "MaxDataServiceVersion": "3.0;NetFx"
   

正文:

var body = '''
--batch_8360b73e-53ce-4ab8-8de8-3894086bd694
content-type: multipart/mixed; boundary=changeset_7d6bec6f-eced-4cd9-8b40-9f9c528fd987
Connection: Keep-Alive
DataServiceVersion: 3.0
MaxDataServiceVersion: 3.0;NetFx

--changeset_7d6bec6f-eced-4cd9-8b40-9f9c528fd987      
Content-Type: application/http
Content-Transfer-Encoding: binary
DataServiceVersion: 3.0

POST https://stg1235.table.core.windows.net/Tahsel HTTP/1.1
Accept: application/json;odata=minimalmetadata        
Accept-Encoding: identity
x-ms-date: 2021-12-06 22:12:15.862319Z
Accept-Charset: UTF-8
x-ms-version: 2020-10-02
content-type: application/json
content-length: 259
If-Match: *

"PartitionKey":"info","RowKey":"session_e1a63e98-76f5-40e5-a529-bf065c025201","accId":"a9ee53f4-b61a-4bfa-a02a-378d45ce1996","accTitle":"147","amount":null,"userId":null,"userTitle":null,"pwd":null,"isAdmin":null,"accounts":null,"note":null,"TimeStamp":null

--changeset_7d6bec6f-eced-4cd9-8b40-9f9c528fd987      
Content-Type: application/http
Content-Transfer-Encoding: binary
DataServiceVersion: 3.0

POST https://stg1235.table.core.windows.net/Tahsel HTTP/1.1
Accept: application/json;odata=minimalmetadata        
Accept-Encoding: identity
x-ms-date: 2021-12-06 22:12:15.862319Z
Accept-Charset: UTF-8
x-ms-version: 2020-10-02
content-type: application/json
content-length: 259
If-Match: *

"PartitionKey":"info","RowKey":"session_a9ee53f4-b61a-4bfa-a02a-378d45ce1996","accId":"a9ee53f4-b61a-4bfa-a02a-378d45ce1996","accTitle":"147","amount":null,"userId":null,"userTitle":null,"pwd":null,"isAdmin":null,"accounts":null,"note":null,"TimeStamp":null

--changeset_7d6bec6f-eced-4cd9-8b40-9f9c528fd987      
--batch_8360b73e-53ce-4ab8-8de8-3894086bd694
''';

响应正文是这样的:

--batchresponse_653e0e1c-9c26-4ae4-b719-73ac6941ea35  
Content-Type: multipart/mixed; boundary=changesetresponse_88428c7e-a6c1-42b2-88d4-3e5302598b3e

--changesetresponse_88428c7e-a6c1-42b2-88d4-3e5302598b3e
Content-Type: application/http
Content-Transfer-Encoding: binary

HTTP/1.1 400 Bad Request
DataServiceVersion: 1.0;
Content-Type: application/xml;charset=utf-8

<?xml version="1.0" encoding="utf-8"?><error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"><code>InvalidInput</code><message xml:lang="en-US">0:An error occurred while processing this request.
RequestId:423d29a2-f002-0060-6dee-eab0ca000000        
Time:2021-12-06T22:12:19.5460529Z</message></error>   
--changesetresponse_88428c7e-a6c1-42b2-88d4-3e5302598b3e--
--batchresponse_653e0e1c-9c26-4ae4-b719-73ac6941ea35--

我还尝试http.MultipartRequest 将有效负载作为字段发送一次,然后作为文件发送一次,但都失败了

我使用http.Request 成功发送和接收所有CRUD 操作的数据!

【问题讨论】:

【参考方案1】:
'--changeset_7d6bec6f-eced-4cd9-8b40-9f9c528fd987--'

结束更改集必须有一个结束--

【讨论】:

以上是关于表存储上的 azure REST 实体组事务上的 InvalidInput的主要内容,如果未能解决你的问题,请参考以下文章

Azure统计事务数量

Windows Phone 8 上的 Azure 表存储使用啥库?

C# 适用于 Azure 表存储上的地理数据的类型

源数据集中的动态工作表名称:Azure 数据工厂上的(Excel(Blob 存储))。 - 错误:请为您的数据集选择一个工作表

使用 Rest Api 查询 Azure 表存储

Azure,中间表上的聚集索引和性能影响