Is OData RESTful?

I am writing a WEB API project where I use OData to search for resource requests. The service must be RESTful. But I'm not sure OData is RESTful due to the URI format.

Wherever I look, the REST URI format is as follows:

http://example.com/resources/142 

But the OData URI format should be like this

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

I am not sure that both rights for REST or OData are not completely RESTful.

+5
source share
3 answers

If the service you write should be RESTful and you are worried about the URI format, then you should do some research on this, because the semantics of the URI are completely unrelated to REST.

The only restrictions that REST imposes on URIs are that they are considered atomic identifiers, that is, they cannot be divided into parts so that they can be understood, and that one URI identifies one and only one resource. In addition, the semantics and format of the URI are irrelevant. For REST, it is important how the client receives the URI. If they read URI patterns from the documentation and fill placeholders with values, then this is not RESTful. You should do some HATEOAS research if this is new to you.

+7
source

The URI is not so strict as to call it REST-ful. There are no standards for checking your service and saying: “This is REST” or “This is not REST”.

Regardless of whether the URI is:

 http://my.service/users/user-1/ 

OR

 http://my.service/users/1/ 

OR

 http://my.service/users(1) 

It can still be a REST-ful service.

+1
source

(I would add this as a comment, but I have no reputation.)

Here are a couple of good questions about this topic on SO:

What I take from this is that there is more to the RESTful API than in the URI format, and OData is more about the content of the messages than in the architecture, so if you adhere to the principles of REST with OData, then this might be considered RESTful.

0
source

Source: https://habr.com/ru/post/1205938/


All Articles