Search code examples
resturiodata

Is OData RESTful?


I am writing an WEB API project where I use OData for advcened querying of resources. The service should be RESTful. But I am not sure if OData is RESTful because of URI format.

Everywhere I look REST URI format looks like this

http://example.com/resources/142

But OData URI format should be like this

http://example.com/resources(142)

I am not sure if both is right for REST or OData is not completly RESTful.


Solution

  • If the service you're writing should be RESTful, and you are worried about URI format, then you should do some research on the subject, because URI semantics are entirely irrelevant to REST.

    The only constraints REST imposes on URIs is that they are treated as atomic identifiers, meaning they can't be split in parts in order to be understood, and that one URI identifies one and only one resource. Other than that, URI semantics and format are irrelevant. What matters to REST is how the client gets the URI. If they are reading URI patterns from documentation and filling placeholders with values, then that's not RESTful. You should do some research on HATEOAS if that's new for you.