2012-04-03 6 views
0

데이터를 업데이트 할 일괄 요청이 있습니다. 데이터는 : 나는 같은 배치에서,변경 집합의 OData 참조 요청

  1. 이 항목이 새로 생성 된 항목에 대한
  2. 업데이트 RefItem 참조를 작성해야합니다

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

    . (가정하자 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-...

누군가 내가 틀린 곳을 말해 줄 수 있습니까? 감사합니다. .

답변

0

일괄 요청이 스트림으로 처리됩니다. 따라서 이미 본 콘텐츠 ID 만 참조 할 수 있습니다. 위의 샘플은 해당 콘텐츠 ID로 요청 작업 전에 콘텐츠 ID 1을 참조합니다. 그것은 유효하지 않습니다.

먼저 새 인스턴스 (POST)를 만든 다음 $ 링크 URL을 통해 해당 인스턴스에 대한 참조를 추가해야합니다.