HTTP PUT method

The HTTP PUT operation is used for a full replacement of an OSLC resource. The PUT method updates both literal properties and local resource properties, and it deletes any local resource properties that are not included in the request.

The following rules apply when you use the PUT method to replace an OSLC resource:

  • All literal properties that are specified in the request document are updated. Any literal property that is not specified as part of the request is not impacted explicitly. However, it can be implicitly impacted by the business logic that is attached to the resource. This rule is the same as when you use the PATCH method to update a resource.
  • All local resource properties are replaced by corresponding property values from the request. If the resource property is not included in the request, the corresponding resource is deleted. If the resource property is included, its value replaces the value in the server.
  • Reference resources cannot be updated explicitly. However, you can update properties that refer to the resource, and the properties follow the update model of literal properties. This rule is the same as when you use the PATCH method to update a resource.

In the following examples, the work task resource has one literal property, taskname, and one resource property parts. The parts property points to the local resource parts and is associated with two parts records. If a PUT request contains the taskname property and no parts property, the task name is updated and the parts data is deleted.

Example: Updating a literal property

The following method updates the literal property, taskname:
PUT http://yourserver/oslc/so/WorkTask/123

{
   "dcterms:taskname": "Check-out Leaking – Modified for Test"
}
If the request is processed successfully, the OSLC client receives the following response:
204 No Content
ETag: 1376596202470

The task name is changed to Check-out Leaking – Modified for Test. Because the parts data was not included in the method, the parts records are deleted.

Example: Updating a local resource property

The following method updates the resource property, parts:
PUT http://yourserver/oslc/so/WorkTask/123

{
   “spi:parts”: [
	{
		 “spi:partsid": "0000000067",
 "spi:quantity": 5
            }
]
}
If the request is processed successfully, the OSLC client receives the following response:
204 No Content
ETag: 1376596202470

A search is made for a parts record with the ID 0000000067. If such a parts record exists, it is updated. If no match is found, a new parts record is created. All other parts data for this work task resource is deleted. Because the taskname property is not included in the method, the task name is not part of the request and the value is unaffected.