Examples for Batch Requests
This section provides examples for batch requests
Batch Request for Creating Parts
The following is a batch request with change sets which creates parts.
POST /Windchill/servlet/odata/ProdMgmt/$batch HTTP/1.1
CSRF_NONCE: <Use the value from Fetch NONCE example>
Content-Type: multipart/mixed;boundary=batch_request
--batch_request
Content-Type:multipart/mixed;boundary=changeset_abc
--changeset_abc
Content-Type: application/http
Content-Transfer-Encoding:binary
Content-Id: 1
POST /Windchill/servlet/odata/ProdMgmt/Parts HTTP/1.1
Content-Type: application/json
{
"Name":"BatchPart1",
"Context@odata.bind": "Containers('OR:wt.pdmlink.PDMLinkProduct:76625')"
}
--changeset_abc
Content-Type: application/http
Content-Transfer-Encoding:binary
Content-Id: 2
POST /Windchill/servlet/odata/ProdMgmt/Parts HTTP/1.1
Content-Type: application/json
{
"Name":"BatchPart2",
"Context@odata.bind": "Containers('OR:wt.pdmlink.PDMLinkProduct:76625')"
}
--changeset_abc--
--batch_request--
The response to the batch request is as below:
--batch_3487ef0a-9598-41cb-a3cf-1d8616ed9e58
Content-Type: multipart/mixed; boundary=changeset_2f39c1fb-0e4b-4a60-9e2d-89cab451db7f
--changeset_2f39c1fb-0e4b-4a60-9e2d-89cab451db7f
Content-Type: application/http
Content-Transfer-Encoding: binary
Content-ID: 1
HTTP/1.1 201 Created
OData-Version: 4.0
Content-Type: application/json;odata.metadata=minimal
Content-Length: 1149
{"@odata.context":"$metadata#Parts","ID":"OR:wt.part.WTPart:601168","Name":"BatchPart1","Number":"0000019103","EndItem":false,"TypeIcon":{"Path":"https://windchill.ptc.com/Windchill/wtcore/images/part.gif","Tooltip":"Part"},"Identity":"0000019103, BatchPart1, Demo Organization, A","GeneralStatus":null,"ShareStatus":null,"ChangeStatus":null,"Supersedes":null,"AssemblyMode":{"Value":"separable","Display":"Separable"},"DefaultUnit":{"Value":"ea","Display":"each"},"DefaultTraceCode":{"Value":"0","Display":"Untraced"},"Source":{"Value":"make","Display":"Make"},"ConfigurableModule":{"Value":"standard","Display":"No"},"GatheringPart":false,"PhantomManufacturingPart":false,"BOMType":null,"AlternateNumber":null,"View":"","CheckoutState":"Checked in","CheckOutStatus":"","Comments":null,"State":{"Value":"INWORK","Display":"In Work"},"LifeCycleTemplateName":"Basic","VersionID":"VR:wt.part.WTPart:601167","Revision":"A","Version":"A.0","Latest":true,"FolderName":null,"CabinetName":"Default","FolderLocation":"/Default","OrganizationName":"Demo Organization","CreatedOn":"2010-04-20T08:32:51Z","LastModified":"2010-04-20T08:32:51Z"}
--changeset_2f39c1fb-0e4b-4a60-9e2d-89cab451db7f
Content-Type: application/http
Content-Transfer-Encoding: binary
Content-ID: 2
HTTP/1.1 201 Created
OData-Version: 4.0
Content-Type: application/json;odata.metadata=minimal
Content-Length: 1149
{"@odata.context":"$metadata#Parts","ID":"OR:wt.part.WTPart:601176","Name":"BatchPart2","Number":"0000019104","EndItem":false,"TypeIcon":{"Path":"https://windchill.ptc.com/Windchill/wtcore/images/part.gif","Tooltip":"Part"},"Identity":"0000019104, BatchPart2, Demo Organization, A","GeneralStatus":null,"ShareStatus":null,"ChangeStatus":null,"Supersedes":null,"AssemblyMode":{"Value":"separable","Display":"Separable"},"DefaultUnit":{"Value":"ea","Display":"each"},"DefaultTraceCode":{"Value":"0","Display":"Untraced"},"Source":{"Value":"make","Display":"Make"},"ConfigurableModule":{"Value":"standard","Display":"No"},"GatheringPart":false,"PhantomManufacturingPart":false,"BOMType":null,"AlternateNumber":null,"View":"","CheckoutState":"Checked in","CheckOutStatus":"","Comments":null,"State":{"Value":"INWORK","Display":"In Work"},"LifeCycleTemplateName":"Basic","VersionID":"VR:wt.part.WTPart:601175","Revision":"A","Version":"A.0","Latest":true,"FolderName":null,"CabinetName":"Default","FolderLocation":"/Default","OrganizationName":"Demo Organization","CreatedOn":"2010-04-20T08:32:51Z","LastModified":"2010-04-20T08:32:51Z"}
--changeset_2f39c1fb-0e4b-4a60-9e2d-89cab451db7f--
--batch_3487ef0a-9598-41cb-a3cf-1d8616ed9e58--
Batch Request with References Between Entity and Property Value
In the following example, there are five changesets with following content ID:
• Content-ID: 1_1—Creates a part with the name PARENT.
• Content-ID: 2_1—Creates a part with the name CHILD.
• Content-ID: 3_1—References part PARENT from Content-ID: 1_1 and checks out the part.
• Content-ID: 4_1—References the checked out part PARENT from Content-ID: 3_1. Creates bind relationship with CHILD, which is referenced from Content-ID: 2_1.
• Content-ID: 5_1—References the checked out part PARENT from Content-ID: 3_1 and checks in the part.
--batch_1
Content-Type: multipart/mixed;boundary=changeset_1
--changeset_1
Content-Id: 1_1
Content-Transfer-Encoding: binary
Content-Type: application/http
POST /Windchill/servlet/odata/v2/ProdMgmt/Parts HTTP/1.1
Accept: application/json
Content-Type: application/json
{"Context@odata.bind":"Containers('OR:wt.pdmlink.PDMLinkProduct:71864')","AssemblyMode":{"Value":"separable"},"DefaultUnit":{"Value":"ea"},"GatheringPart":false,"DefaultTraceCode":{"Value":"0"},"PhantomManufacturingPart":false,"Source":{"Value":"make"},"Name":"PARENT"}
--changeset_1--
--batch_1
Content-Type: multipart/mixed;boundary=changeset_2
--changeset_2
Content-Id: 2_1
Content-Transfer-Encoding: binary
Content-Type: application/http
POST /Windchill/servlet/odata/v2/ProdMgmt/Parts HTTP/1.1
Accept: application/json
Content-Type: application/json
{"Context@odata.bind":"Containers('OR:wt.pdmlink.PDMLinkProduct:71864')","AssemblyMode":{"Value":"separable"},"DefaultUnit":{"Value":"ea"},"GatheringPart":false,"DefaultTraceCode":{"Value":"0"},"PhantomManufacturingPart":false, "Source":{"Value":"make"},"Name":"CHILD"}
--changeset_2--
--batch_1
Content-Type: multipart/mixed;boundary=changeset_3
--changeset_3
Content-Id: 3_1
Content-Transfer-Encoding: binary
Content-Type: application/http
POST $1_1/PTC.ProdMgmt.CheckOut HTTP/1.1
Accept: application/json
Content-Type: application/json
{}
--changeset_3--
--batch_1
Content-Type: multipart/mixed;boundary=changeset_4
--changeset_4
Content-Id: 4_1
Content-Transfer-Encoding: binary
Content-Type: application/http
POST $3_1/Uses HTTP/1.1
Accept: application/json
Content-Type: application/json
{"TraceCode":{"Value":"L"},"FindNumber":"F001","Quantity":2,"Uses@odata.bind":"$2_1","Unit":{"Value":"ea"},"LineNumber":100}
--changeset_4--
--batch_1
Content-Type: multipart/mixed;boundary=changeset_5
--changeset_5
Content-Id: 5_1
Content-Transfer-Encoding: binary
Content-Type: application/http
POST $3_1/PTC.ProdMgmt.CheckIn HTTP/1.1
Accept: application/json
Content-Type: application/json
{}
--changeset_5--
--batch_1--