Tuesday, January 3, 2012

What is OData and How to test OData calls




The Open Data Protocol (OData) is an open web protocol for querying and updating data. The protocol allows for a consumer to query a datasource over the HTTP protocol and get the result back in formats like Atom, JSON or plain XML, including pagination, ordering or filtering of the data.


Many of the building blocks that make up OData are standardized via Atom and AtomPub. The OData specification is available under the Microsoft Open Specification Promise (OSP). Microsoft has released an OData software development kit (SDK) consisting of libraries for .NET, PHP, Java, JavaScript, webOS, and the iPhone.

How to test?

Firefox plugin called "Rest Client" is available to test OData calls.

Ways to test various CRUD operations:

1. CREATE:

    Set Method = POST
    content-type = application/atom+xml
    Enter payload in "Request Body" and execute.

2. UPDATE:
    We can use Method = PUT, but this is kind of outdated instead user Merge. To use MERGE set header
    X-HTTP-METHOD = MERGE.
    URI = http://mysite.com/services/odata/user('user_id')
    Enter valid payload and execute the operation.

3. DELETE:
    Method = DELETE
    URI = http://mysite.com/services/odata/user('user_id')
    execute the operation.

No comments:

Post a Comment