Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

A Look at OData

A quick look at the OData protocol and some of the bigger points where is comes from and what it can do.

  • Be the first to comment

A Look at OData

  1. 1. A LOOK AT ODATA Chris Woodruff
  2. 2. ChrisWoodruff EMAIL SKYPE cwoodruff TWITTER @cwoodruff PHONE 616.724.6885
  3. 3. Open Data Protocol (OData) What is OData? •OData is anWeb Standard and Protocol that defines the best practice for building and consuming RESTfulAPIs. •OData helps you focus on your business logic while building RESTfulAPIs without having to worry about the approaches to define your APIs. •OData RESTfulAPIs are easy to consume.
  4. 4. What is a Protocol in the InternetWorld?
  5. 5. Some Basics about HTTP Resources These are the URLs you use to get to pages on the web Request Headers These are additional instructions that are sent with the request.These might define what type of response is required or authorization details. RequestVerbs These describe what you want to do with the resource. A browser typically issues a GET verb to instruct the endpoint it wants to get data, however there are many other verbs available including things like POST, PUT and DELETE. Request Body Data that is sent with the request. For example a POST (creation of a new item) will required some data which is typically sent as the request body in the format of JSON or XML. Response Body This is the main body of the response. If the request was to a web server, this might be a full HTML page. Response Status codes These codes are issues with the response and give the client details on the status of the request.
  6. 6. Some Basics about HTTP -Verbs GET Requests a representation of the specified resource. Requests using GET should only retrieve data and should have no other effect. POST Requests that the server accept the entity enclosed in the request as a new subordinate of the web resource identified by the URI. PUT Requests that the enclosed entity be stored under the supplied URI. DELETE Deletes the specified resource.
  7. 7. Some Basics about HTTP – Response Codes 1XX Request received, continuing process. This class of status code indicates a provisional response, consisting only of the Status-Line and optional headers, and is terminated by an empty line. 2XX This class of status codes indicates the action requested by the client was received, understood, accepted and processed successfully. 3XX This class of status code indicates the client must take additional action to complete the request. 4XX The 4xx class of status code is intended for cases in which the client seems to have errored. 5XX The server failed to fulfill an apparently valid request. Response status codes beginning with the digit "5" indicate cases in which the server is aware that it has encountered an error or is otherwise incapable of performing the request.
  8. 8. What is REST? •REST stands for Representational State Transfer. •An architectural style for building loosely coupled systems •REST is not a "standard".There will never be aW3C recommendataion for REST •It relies on a stateless, client-server, cacheable communications protocol -- and in virtually all cases, the HTTP protocol is used.
  10. 10. How does OData use REST? •ODataAPIs are just Collections ofTyped Entities (Resources) •OData services expose all these Resources via URIs •OData services use HTTP Verbs to intereact with Resources •OData services can also expose Actions and Function for custom work
  12. 12. OData in 6 Simple Steps 1. Requesting Resources 2. Requesting an Individual Resource 3. Queries 4. Creating a New Resource 5. Relating Resources 6. Invoking a Function
  13. 13. OData – Requesting Resources GET HTTP/1.1 OData-Version: 4.0 OData-MaxVersion: 4.0
  14. 14. OData – Requesting an Individual Resource GET'russellwhyte') HTTP/1.1 OData-Version: 4.0 OData-MaxVersion: 4.0
  15. 15. OData – Queries GET$select =FirstName,LastName&$orderby=LastName&$top=10 HTTP/1.1 OData-Version: 4.0 OData-MaxVersion: 4.0
  16. 16. Query Options Sorting /Bookmarks?$orderby=Name Filtering /Bookmarks?$filter=year(Created) gt 2007 Paging /Bookmarks?$top=10&$skip=30 Inline expansion /Bookmarks?$expand=Tags Query Projection /Bookmarks?$select=Name,Description
  17. 17. OData – Creating a New Resource POST HTTP/1.1 OData-Version: 4.0 OData-MaxVersion: 4.0 Content-Type: application/json { 'UserName':'lewisblack', 'FirstName':'Lewis', 'LastName':'Black', 'Emails':[ '' ] }
  18. 18. OData – Relating Resources POST'lewisblack') /Trips/$ref HTTP/1.1 OData-Version: 4.0 OData-MaxVersion: 4.0 Content-Type: application/json { '':' jr513b))/TripPinServiceRW/People('russellwhyte')/Trips(0)' }
  19. 19. OData – Invoking an Action GET'russe llwhyte')/Trips(0)/Microsoft.OData.SampleService.Models. TripPin.GetInvolvedPeople() HTTP/1.1 OData-Version: 4.0 OData-MaxVersion: 4.0
  20. 20. Wrap Up EMAIL SKYPE cwoodruff TWITTER @cwoodruff PHONE 616.724.6885