2012-04-03 18 views
0

データを更新するバッチ要求があります。 データは:変更セット内のOData参照要求

Item : { 
id : int, 
name : string,  
RefItem : { 
    int : id, 
    name : string } 
} 

私は、同じバッチで、この新しく作成されたアイテムのアイテム

  • 更新RefItem参照を、作成

    1. を必要としています。 ODataの仕様によると((1)すでにデータセット内に存在すると仮定RefItems)

    --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-...

    誰かが私が間違っている場所を教えてもらえますか?おかげさまで

  • 答えて

    0

    バッチリクエストはストリームとして処理されます。したがって、既に見られたコンテンツIDのみを参照することができます。上記のサンプルでは、​​そのコンテンツIDの要求操作前のコンテンツID 1を参照しています。それは有効ではありません。

    まず、新しいインスタンス(POST)を作成してから、そのインスタンスへの参照を$リンクURL経由で追加する必要があります。

    関連する問題