Program guide > Access data with the REST data service > Request protocols for the REST data service



Update requests with REST data services

The WebSphere eXtreme Scale REST data service supports update requests for entities, entity primitive properties, and so on.


Update an entity

An UpdateEntity Request can be used to update an existing eXtreme Scale entity. The client can use an HTTP PUT method to replace an existing eXtreme Scale entity, or use an HTTP MERGE method to merge the changes into an existing eXtreme Scale entity.

When updating the entity, the client may specify if the entity, in addition to being updated, should be automatically linked to other existing entities in the data service that are related through single valued to-one associations.

The property of the entity to be updated is in the request payload. The property is parsed by the REST data service and then set to the correspondent property on the entity. For the AtomPub format, the property is specified as a <d:PROPERTY_NAME> XML element. For JSON, the property is specified as a property of a JSON object.

If a property is missing in the request payload, the REST data service sets the entity property value to the java default value for HTTP PUT method. However, the database backend might reject such a default value if, for example, the column is not nullable in the database. Then a 500 (Internal Server Error) response code will be returned to indicate an Internal Server Error. If a property is missing in the HTTP MERGE request payload, the REST data service will not change the existing property value.

If there are duplicate properties specified in the payload, the last property will be used. All the previous values with the same property name are ignored by the REST data service.

If the payload contains a non-existent property, the REST data service returns a 400 (Bad Request) response code to indicate the request sent by the client was syntactically incorrect.

As part of the serialization of a resource, if the payload of an Update request contains any of the key properties for the entity, the REST data service ignores those key values since entity keys are immutable.

For details on UpdateEntity request, refer to: MSDN Library: UpdateEntity Request.

An UpdateEntity request updates the city name of Customer('IBM') to 'Raleigh'.


AtomPub


JSON


Update an entity primitive property

The UpdatePrimitiveProperty Request can update a property value of an eXtreme Scale entity. The property and value to be updated are in the request payload. The property cannot be a key property since eXtreme Scale does not allow clients to change entity keys.

For more details on the UpdatePrimitiveProperty request, refer to: MSDN Library: UpdatePrimitiveProperty Request.

Here is an UpdatePrimitiveProperty request example. In this example, we update the city name of Customer('IBM') to 'Raleigh'.


AtomPub


JSON


Update an entity primitive property value

The UpdateValue Request can update a raw property value of an eXtreme Scale entity. The value to be updated is represented as a raw value in the request payload. The property cannot be a key property since eXtreme Scale does not allow clients to change entity keys.

The content type of the request can be “text/plain” or “application/octet-stream” depending on the property type. Refer to section 6.3.1.4 for more details.

For more details on the UpdateValue request, refer to: MSDN Library: UpdateValue Request

Here is an UpdateValue request example. In this example we update the city name of Customer('IBM') to 'Raleigh'.


Update a link

The UpdateLink request can be used to establish an association between two eXtreme Scale entity instances. The association can be a single valued (to-one) relation or a multi valued (to-many) relation.

Update a link between two eXtreme Scale entity instances can not only establish associations, but also remove associations. For example, if the client establishes a to-one association between an Order(orderId=5000,customer_customerId='IBM') entity and entity and Customer('ALFKI') instance, it has to dissociate the Order(orderId=5000,customer_customerId='IBM') entity and entity from its currently associated Customer instance.

If either of the entity instances specified in the UpdateLink request cannot be found, the REST data service returns a 404 (Not Found) response.

If the URI of the UpdateLink request specifies a non-existent association, the REST data service returns a 404 (Not Found) response to indicate the link cannot be found.

If the URI specified in the UpdateLink request payload does not resolve to the same entity or the same key as specified in the URI, if exists, then the eXtreme Scale Rest Data Service returns a 400 (Bad Request) response.

If the UpdateLink request payload contains multiple links, then the REST data service will only parse the first link. The rest of the links are ignored.

For more details on the UpdateLink request, refer to: MSDN Library: UpdateLink Request.

Here is an UpdateLink request example. In this example, we update the customer relation of Order(orderId=5000,customer_customerId='IBM') entity and from Customer('IBM') to Customer('IBM').

Remember: The previous example is for illustration only. Because all associations are typically key-associations for a partitioned grid, the link cannot be changed.


AtomPub


JSON


Parent topic:

Request protocols for the REST data service

Related reference

Retrieve requests with the REST data service

Retrive non-entities with REST data services

Insert requests with REST data services

Delete requests with REST data services