Questions tagged [rest]

REST (Representational State Transfer) is a style of software architecture for distributed hypermedia systems such as the World Wide Web. It has increased in popularity relative to RPC architectures such as SOAP due to the intrinsic de-coupling of client from server that comes from having a uniform interface between heterogeneous systems.

(Not to be confused with or reST)

REST (REpresentational State Transfer) is an architectural style that uses identification of resources; manipulation of resources through representations; self-descriptive messages, and hypermedia as the engine of application state, to build distributed systems that are scalable and resilient to change.

The term was introduced and defined in 2000 by Roy Fielding in his doctoral dissertation. Fielding is one of the principal authors of the Hypertext Transfer Protocol (HTTP) specification versions 1.0 and 1.1.

In simple language, REST is an alternative to SOAP based web services. Where SOAP tries to model the exchange between client and server as calls to objects, REST tries to be faithful to the web domain.

Resources


Examples

A website's RESTful API is queried to find out information on a user, specified by a numerical ID.

Request Type: GET
http://www.api.website.com/users/12345

Returns, in a format for this example:

{"username" : "theuser",
 "userid"   :  12345,
 "first"    : "George",
 "last"     : "Washington"}

Question Index

Searching

REST search interface and the idempotency of GET
RESTful URL design for search
Best practice for implementing long-running searches with REST
Querystring in REST Resource url
What is the best way to create RESTful complex queries?
Question on REST conventions: retrieving information where lots of params are needed

Resource Design

How to design a RESTful collection resource?
RESTful design of a resource with binary states
RESTFful/Resource Oriented Design
RESTful resource - accepts a list of objects
RESTful API creates a globally unique resource
REST's 'resource communication mechanisms' and 'on-the-fly' improvement of a client's knowledge of them
How to move a REST resource?

Media Types

REST Media type explosion
Creating hypermedia links in a custom media-type
Custom content types: XLink vs. Atom

Books

Related tags

92665 questions
6265
votes
42 answers

What is the difference between POST and PUT in HTTP?

Background Information Analysis: According to RFC 2616, § 9.5, POST is used to create a resource: The POST method is used to request that the origin server accept the entity enclosed in the request as a new subordinate of the resource identified by…
alex
  • 74,215
  • 9
  • 49
  • 57
4170
votes
35 answers

What exactly is RESTful programming?

What exactly is RESTful programming?
hasen
  • 161,647
  • 65
  • 194
  • 231
3723
votes
31 answers

How do I POST JSON data with cURL?

I use Ubuntu and installed cURL on it. I want to test my Spring REST application with cURL. I wrote my POST code at the Java side. However, I want to test it with cURL. I am trying to post a JSON data. Example data is like…
kamaci
  • 72,915
  • 69
  • 228
  • 366
3022
votes
24 answers

HTTP GET with request body

I'm developing a new RESTful webservice for our application. When doing a GET on certain entities, clients can request the contents of the entity. If they want to add some parameters (for example sorting a list) they can add these parameters in the…
Evert
  • 93,428
  • 18
  • 118
  • 189
1345
votes
14 answers

SOAP vs REST (differences)

I have read articles about the differences between SOAP and REST as a web service communication protocol, but I think that the biggest advantages for REST over SOAP are: REST is more dynamic, no need to create and update UDDI(Universal…
Abdulaziz
  • 13,694
  • 3
  • 13
  • 12
1290
votes
18 answers

HTTP response code for POST when resource already exists

I'm building a server that allows clients to store objects. Those objects are fully constructed at client side, complete with object IDs that are permanent for the whole lifetime of the object. I have defined the API so that clients can create or…
vmj
  • 13,283
  • 3
  • 18
  • 14
1212
votes
16 answers

Use of PUT vs PATCH methods in REST API real life scenarios

First of all, some definitions: PUT is defined in Section 9.6 RFC 2616: The PUT method requests that the enclosed entity be stored under the supplied Request-URI. If the Request-URI refers to an already existing resource, the enclosed entity SHOULD…
Dmitry Kudryavtsev
  • 16,354
  • 4
  • 25
  • 32
1096
votes
24 answers

How to set the Content-Type header for an HttpClient request?

I'm trying to set the Content-Type header of an HttpClient object as required by an API I am calling. I tried setting the Content-Type like below: using (var httpClient = new HttpClient()) { httpClient.BaseAddress = new…
mynameiscoffey
  • 15,244
  • 5
  • 33
  • 45
1046
votes
17 answers

Is an entity body allowed for an HTTP DELETE request?

When issuing an HTTP DELETE request, the request URI should completely identify the resource to delete. However, is it allowable to add extra meta-data as part of the entity body of the request?
Haacked
  • 58,045
  • 14
  • 90
  • 114
1025
votes
9 answers

Which status code should I use for failed validations or invalid duplicates?

I am building an application with a REST-based API and have come to the point where I am specifying status codes for each requests. What status code should i send for requests failing validation or where a request is trying to add a duplicate in my…
alexn
  • 57,867
  • 14
  • 111
  • 145
996
votes
11 answers

Posting a File and Associated Data to a RESTful WebService preferably as JSON

In an application I am developing RESTful API and we want the client to send data as JSON. Part of this application requires the client to upload a file (usually an image) as well as information about the image. I'm having a hard time tracking down…
Gregg
  • 34,973
  • 19
  • 109
  • 214
876
votes
7 answers

Best practices for API versioning?

Are there any known how-tos or best practices for web service REST API versioning? I have noticed that AWS does versioning by the URL of the endpoint. Is this the only way or are there other ways to accomplish the same goal? If there are multiple…
Swaroop C H
  • 16,902
  • 10
  • 43
  • 50
840
votes
18 answers

Best Practices for securing a REST API / web service

When designing a REST API or service are there any established best practices for dealing with security (Authentication, Authorization, Identity Management) ? When building a SOAP API you have WS-Security as a guide and much literature exists on the…
Nathan
  • 12,290
  • 3
  • 29
  • 28
813
votes
26 answers

Setting Authorization Header of HttpClient

I have an HttpClient that I am using for a REST API. However I am having trouble setting up the Authorization header. I need to set the header to the token I received from doing my OAuth request. I saw some code for .NET that suggests the…
Stephen Hynes
  • 22,071
  • 6
  • 18
  • 20
792
votes
14 answers

RESTful Authentication

What does RESTful Authentication mean and how does it work? I can't find a good overview on Google. My only understanding is that you pass the session key (remeberal) in the URL, but this could be horribly wrong.
Jim Keener
  • 9,255
  • 4
  • 24
  • 24
1
2 3
99 100