To test the Update operation, use Firefox with REST Client Add-On.
Consider creating a user in the backend for this test, since you may require the proper permissions to change user information.
In addition, you must configure your REST Client Add-On to use the X-CSRF-Token (Cross-Site Request Forgery) protection.
You require authorization to change user data in the SAP backend system.
An UPDATE operation uses the HTTP PUT method and is called using the same URL as the READ operation.
Change the method to PUT in the Firefox REST client.
Method: PUT
URL: URL of the service, for example, .../sap/opu/odata/sap/z_user_bor/z_user_borCollection('Aviszovski')
Request Header: Click Add Request Header and add the HTTP header for the X-CSRF-Token protection as shown in the image below.
Name |
Value |
X-CSRF-Token |
Paste the data for the token you have copied, for example, QXyUmor32424241243124mx== |
Content-Type |
Enter the following:application/atom+xml |
Insert the same URL as the one for the READ operation.
<Gateway_host>:<port_number>/sap/opu/data/sap/zsh_user_bor/zsh_user_borCollection('avizovski')
You can provide the user credentials in advance using the button, Login, or when prompted.
In this example, the Request Body is mostly the same as the one used for the CREATE operation.
<atom:id>tag:com.sap,2010-06-24:/subscriptions/123<atom:id>
<atom:title>Create new user</atom:title>
<atom:author/>
<atom:updated></atom:updated>
<atom:content type="application/xml">
<m:properties xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices>
<d:building m:null="true"/>
< d:comm_type m:null="true"/>
<d:department m:null="true"/>
<d:e_mail m:null="true"/>
<d:fax_number m:null="true"/>
<d:firstname >JOSEPH</d:firstname />
<d:floor m:null="true"/>
<d:fullname> </d:fullname>
<d:islocked m:null="true"/>
<d:language m:null="true"/>
<d:lastname>AVIZOVSKI</d:lastname >
<d:maxrows>0</d:maxrows>
<d:password>Initial</d:password >
<d:room m:null="true"/>
<d:telephone m:null="true"/>
<d:title>Dr. </d:title>
<d:userid m:null="true"/>
<d:username>AAVIZOVSKI</d:username>
<d:withusername m:null="true"/>
</m:properties>
</atom:content>
</atom:entry>
Change the value in a field for testing, for example, firstname from Alexis to Joseph, and click Send.
Upon successful update, you should receive an HTTP “Status Code: 204 No Content”.
This means the update succeeded but as implied by the status text, there is no response body returned.
To perform a quick verification of the update, simply change the HTTP method to GET and click Send. This performs a READ of the same object and you can verify the results in the Response Body or Formatted XML tab.