Previous post https://blogs.sap.com/2017/10/26/using-a-third-party-library-with-sapui5-application-sap-hana-cloud-development-scenario-part-2/
Testing Odata Service :
In this part we have to validate our Odata service befor building the Front End application.
For this i will use Advanced Rest Client ( chrome Extension ). Create a new Request put the url to call Event Entity and added the “$top” parameter to the url to select just the first two events from the whole list.
If you are not familiar with Odata you can see this blog https://blogs.sap.com/2016/02/08/odata-everything-that-you-need-to-know-part-1/
This is the final set up we need to use GET operation and i added X-Csrf-Token = Fetch to use the result in the next operation
https://mdcpXXXXXXtrial.hanatrial.ondemand.com/Calendar/services/BookingEBC.xsodata/Events?$top=2 Events https://mdcpXXXXXXtrial.hanatrial.ondemand.com:443/Calendar/services/BookingEBC.xsodata/Events https://mdcpXXXXXXtrial.hanatrial.ondemand.com:443/Calendar/services/BookingEBC.xsodata/Events(‘00065ec7-9051-4798-a321-7dfc4eec09c9’) 00065ec7-9051-4798-a321-7dfc4eec09c9 Empty Task TEST 2017-05-11T09:00 2017-05-11T10:30 #77DD77 F 6f9137f3-092a-408b-9385-549ed7116ffb 2017 5 11 ONGABI https://mdcpXXXXXXtrial.hanatrial.ondemand.com:443/Calendar/services/BookingEBC.xsodata/Events(‘001e0529-8218-4a40-ad20-d7374516c38a’) 001e0529-8218-4a40-ad20-d7374516c38a Empty Task 2017-08-17T11:00 2017-08-17T12:30 #77DD77 F 6f9137f3-092a-408b-9385-549ed7116ffb 2017 8 17
If the call is executed correctly we should see a result similar to my XML. Pick one ID to check the GetDetail_Entity method by changing the URL.
https://mdcpXXXXXXtrial.hanatrial.ondemand.com/Calendar/services/BookingEBC.xsodata/Events(‘001e0529-8218-4a40-ad20-d7374516c38a’)?$format=json { “d”: { “__metadata”: { “type”: “Calendar.services.BookingEBC.EventsType”, “uri”: “https://mdcp601643trial.hanatrial.ondemand.com:443/Calendar/services/BookingEBC.xsodata/Events(‘001e0529-8218-4a40-ad20-d7374516c38a’)” }, “ID”: “001e0529-8218-4a40-ad20-d7374516c38a”, “TITLE”: “Empty Task”, “START_DATE”: “2017-08-17T11:00”, “END_DATE”: “2017-08-17T12:30”, “COLOR”: “#77DD77”, “STATUS”: “F”, “DESCRIPTION”: “6f9137f3-092a-408b-9385-549ed7116ffb”, “YEAR”: 2017, “MONTH”: 8, “DAY”: 17, “OWNERID”: “ ”, “CUST_COSTCENTER”: “ ”, “SREP_COSTCENTER”: “ ” } }
Back to Advanced Rest Client, copy the X-CSRF-TOKEN value and use it to send a PUT operation to modify the Event Content
Change the X-Csrf-Token value and the Request type and URL
https://mdcpXXXXXXtrial.hanatrial.ondemand.com/Calendar/services/BookingEBC.xsodata/Events(‘001e0529-8218-4a40-ad20-d7374516c38a’)
Change the body by putting the same JSON result from the GET operation request and modify some value and Execute the request.
Final JSON { “__metadata”: { “type”: “Calendar.services.BookingEBC.EventsType”, “uri”: “https://mdcpXXXXXXtrial.hanatrial.ondemand.com:443/Calendar/services/BookingEBC.xsodata/Events(‘001e0529-8218-4a40-ad20-d7374516c38a’)” }, “ID”: “001e0529-8218-4a40-ad20-d7374516c38a”, “TITLE”: “Empty Task Test”, “START_DATE”: “2017-08-17T11:00”, “END_DATE”: “2017-08-17T12:30”, “COLOR”: “#77DD77”, “STATUS”: “F”, “DESCRIPTION”: “6f9137f3-092a-408b-9385-549ed7116ffb”, “YEAR”: 2017, “MONTH”: 8, “DAY”: 17, “OWNERID”: “ONGABI”, “CUST_COSTCENTER”: “ ”, “SREP_COSTCENTER”: “ ” }
Change the operation from PUT to GET on the Advanced Rest and check the result
https://mdcpXXXXXXtrial.hanatrial.ondemand.com/Calendar/services/BookingEBC.xsodata/Events(‘001e0529-8218-4a40-ad20-d7374516c38a’)
The response should be like this.
Conslusion :
The Odata service is now ready and we can start the UI part in the next article. http://bit.ly/2i6Vtii #SAP #SAPCloud #AI