on 06-06-2014 10:08 AM
Hi all,
Is it mandatory to write a read operation in a Odata service which is mainly meant for change/update?
regards
Nitesh
Hi,
it is not mandatory that you need to implement read operation. but it is good to implement it because when you want to test update operation in GW client, you can first execute read operation then copy response payload using "Use as Request" button and then do the required update in request and execute PUT operation. also you can then execute GET again to know if the update was successful.
But the answer is, it is not mandatory to write Read operation.
Regards,
Chandra
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am not aware about any other tool to generate payload. but if you observe the request payload, you will be able to create one for yourself.
for e.g. below is the query for PUT operation to update the contact record 1234.
/sap/opu/odata/sap/ZTRAIN_EMP_CONTACT_SRV/contacts('1234')
This will be the request payload. These are the minimum tags that need to be passed along with properties.
<?xml version="1.0" encoding="utf-8"?>
<entry xml:base="http://<host>:port>/sap/opu/odata/sap/ZTRAIN_EMP_CONTACT_SRV/"
xmlns="http://www.w3.org/2005/Atom"
xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"
xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices">
<content type="application/xml">
<m:properties>
<d:Empid>123</d:Empid>
<d:Firstname>ABC</d:Firstname>
<d:Lastname>XYZ</d:Lastname>
</m:properties>
</content>
</entry>
but this will become difficult once you have too many properties etc.
anyway is there any reason you do not want to perform Read operation?
Regards,
Chandra
read is not mandatory but for a create or a query i would do a read too
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Chandra/Krishna,
At the client side when calling the update service call i am getting a CSRF token error. Is there any other way to generate the CSRF token than writing a read operation?
On the client side i am using Sencha touch which has an SAP Odata connector. Hopefully after providing the relevant details that should generate the correct payload.
regards
Nitesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Chandra,
I do agree that my first question was answered.
However the answer to the first question led to other questions. As they are inter-related i think it will be helpful & time saving for others who have similar questions to get the complete picture in one SCN message/ discussion rather than have to look into multiple threads.
Coming to your question of not wanting to write a read operation. My OData service is to change the password of the sap netweaver gateway system. In this context the read operation is of no value. However considering the framework if i am forced to write one to generate the CSRF token it will only be a dummy.
regards
Nitesh
Ok.
I guess you can use method setTokenHandlingEnabled(bTokenHandling?)
and set it to false. by default it is true.
Refer API documentation JsDoc Report - SAP UI development Toolkit for HTML5 - API Reference - sap.ui.model.odata.ODataModel
Regards,
Chandra
Yes Nitesh, As Chandra said it is not mandatory for Update. But it is required for 'Create', since framework tries to read the created entity/record.
Though it is not required, implementing 'read' helps a lot in testing and there is a easy way to do that. Just hardcode the values in the read method, so that the response for read is available at the client and 'use it as request'.
thanks
Krishna
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
95 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.