Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Hot answers tagged

5

As a rule of thumb with RESTful APIs I've found that you should only ever need to do "one hop" when defining relationships between two entities. As soon as you need to start defining relationships across "two hops" it's normally a sign that the endpoint isn't very RESTful any more. Endpoints should only really be concerned with one entity. Remember this isn'...


5

Dynamically selecting the correct API implementation sounds cool, but is actually a nightmare. a REST API exposes a bunch of URIs that identify resources cool URIs don't change here, the interpretation of the URI depends on the implicit version so your URIs do not identify resources by themselves this breaks REST, to some degree Your implicit version ...


3

The format of the response body for an error like 404 can be defined in the Content-Type in the header of the response (Content-Types can be more than just "json", you can define and document your own Content-Types that explain the actual format of the error. See here. Clients can then know what data they are getting back when something happens) This doesn'...


3

It is important to look at why we want to have safe and idempotent methods. ReST is an architectural style for large-scale information systems. Networks are inherently unreliable. So, you have to deal with things like lost, re-ordered, delayed, and duplicated messages, and strategies like caching. Idempotent methods allow you to repeat a request without ...


2

According to RFC 2616 (emphasis mine) Note that RFC 2616 is obsolete; it has been replaced by RFC 7230->RFC 7235. "Safe" is now defined in RFC 7231 Request methods are considered "safe" if their defined semantics are essentially read-only; i.e., the client does not request, and does not expect, any state change on the origin server as a result of ...


1

A background task is not a ressource as users or companies can be. Fielding, when defining REST, offered this definition of a resource: Any information that can be named can be a resource: a document or image, a temporal service (e.g. "today's weather in Los Angeles"), a collection of other resources, a non-virtual object (e.g. a person), and so on. In ...


1

From the example what you seem to want to do is get all the users who have commented on any post in a particular thread. Generally if you find yourself doing complex queries to try and get a specific set of data that is a sign that what you actually need is just a new resource Something like GET /threads/{threadUuid}/all_users_that_commented and let the ...


1

I had different responses for the exceptions but then an Android dev complained that he needed to do some manual checks because of that. This is more important than any of the answer here. If you know the audience to whom the API is addressed you should hear them first. If they have different opinions, sit with them and allow them to expose their ...


1

I am a regular user of the Stack Exchange API. It uses the same schema for errors and for successful responses, the wrapper. Of course, different fields will be filled; just compare the responses to the Site Information call for an existing site: https://api.stackexchange.com/2.2/info?site=softwareengineering and a non-existing one: https://api.stackexchange....


1

How would you handle this scenario? How would you do it with a web site? In HTML, you'd probably have a form, and using input controls you would collect the information that you need, and when the form was submitted the appropriate request would be created by the client and dispatched to the server. From the sound of things, the semantics of this are ...


1

It seems to me you're probably thinking of an operation where a resource (the "item") in your system is updated in some way, possibly within a transaction. This update can very well result in this entity moving from one table to another table. Another likely characteristic of your operation is that it's not idempotent; i.e. you cannot move an entity twice ...


1

To summarize, we need to create a new Job while also passing over the Project Name and CustomerAccount Name since we don't have access to the IDs to use. If the Project is not found, one is automatically created then assigned to the Job about to be created. Keep it simple. You don't need the project id or account id (I assume these are database ids). ...


1

REST doesn't care what spelling you use for your URIs, beyond the basics that they conform with RFC 3986. The machines don't care after that, in much the same way that the compiler doesn't care what variable names you use. Follow any conventions you like. If your URIs have a hierarchical structure, then you can take advantage of dot segments and relative ...


1

Almost everything is a balancing act between performance, usability, maintainability. That said... What's the difference between storing session state on the client versus the server? Where the information is stored determines where it is accessible from. If you only store something client-side, the server obviously won't have any knowledge of it. ...


Only top voted, non community-wiki answers of a minimum length are eligible