SData web service for Update
This article describes how to update an existing resource with the Web API.
To update a resource, you may first retrieve its current state, with a GET
request on the following URL:.
http://myserver:myport/api1/x3/erp/MYENDPOINT/MYCLASS('MYKEY')?representation=MYREPR.$edit
myserver:myport
is your server name and port number. For example localhost:8124
if the SAFE X3 web server is installed locally.MYENDPOINT
is the name of your Sage X3 endpoint.MYCLASS
is the name of the class that you want to query. It may be a standard class like BPCUSTOMER
or a custom class that you have implemented (see the class dictionaries documentation).MYKEY
is the value of the primary key of the resource. If the key is composite, the components are separated by a tilde (~
).MYREPR
is the name of the representation that you want to query. It may be a standard representation like BPCUSTOMER
or a custom one (see the representation dictionaries documentation).Note MYREPR
must be a representation for MYCLASS
. Otherwise you will get an error. A future version of the Web API will allow you to pass only MYREPR
but this version (api1) requires both parameters.
If you have read the resource, you can modify the values of the payload returned by the read request.
But you can also create an update payload from scratch. You do not need to supply values for all the resource's properties in this payload, you can supply only the values that are modified; the server will consider that the missing properties did not change.
http://myserver:myport/api1/x3/erp/MYENDPOINT/MYCLASS('MYKEY')?representation=MYREPR.$edit
If successful, the request will return an HTTP status of 200.
Otherwise it will return an HTTP error status (4xx or 5xx).
The PUT
request returns the new state of the resource after the update. This payload may be slightly different from the one you submitted because the server applied business rules defined in the class and representation before updating the database.
SData 2.0 uses the HTTP ETag
header to detect concurrent modifications on a resource. This feature is not available in this rollout of the Web API.
As described in the overview, you can test interactively with a tool like Postman.