我有批量更新數據的請求。 數據爲:更改集中的OData引用請求
Item : {
id : int,
name : string,
RefItem : {
int : id,
name : string }
}
我需要
- 創建項目
- 這個新創建的項目更新RefItem參考,在同一批次。 (假設RefItems(1)中的數據集已經存在)
根據OData的規格:
--batch_1872-f36a-7ce8
Content-Type: multipart/mixed; boundary=changeset_8c16-9ba3-2260
--changeset_8c16-9ba3-2260
Content-Type: application/http
Content-Transfer-Encoding: binary
PUT $1/$links/ItemRef HTTP/1.1
Content-ID: 2
Accept: application/atomsvc+xml;q=0.8, application/json;q=0.5, /;q=0.1
DataServiceVersion: 1.0
Content-Type: application/json
{"uri":"ItemRefs(1)"}
--changeset_8c16-9ba3-2260
Content-Type: application/http
Content-Transfer-Encoding: binary
POST Products HTTP/1.1
Content-ID: 1
Accept: application/atomsvc+xml;q=0.8, application/json;q=0.5, /;q=0.1
DataServiceVersion: 1.0
Content-Type: application/json
{"id":-1,"name":"seven"}
--changeset_8c16-9ba3-2260--
--batch_1872-f36a-7ce8--
我想它應該工作,但我有響應錯誤:
--batchresponse_4febeba8-dd43-4040-9fdb-866afde5304e Content-Type: multipart/mixed; boundary=changesetresponse_424dbf12-fa9a-4a59-8284-963fa0fa7b77
--changesetresponse_424dbf12-fa9a-4a59-8284-963fa0fa7b77 Content-Type: application/http Content-Transfer-Encoding: binary
HTTP/1.1 500 Internal Server Error Content-ID: 2 X-Content-Type-Options: nosniff DataServiceVersion: 1.0; Content-Type: application/json;charset=utf-8
{"d":{"error":{"code":"","message":{"lang":"ru-RU","value":"An error occurred while processing this request."}}}} --changesetresponse_424dbf12-fa9a-4a59-...
有人可以告訴我我錯了嗎? 謝謝。