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
297
votes
11 answers

How do I make a request using HTTP basic authentication with PHP curl?

I'm building a REST web service client in PHP and at the moment I'm using curl to make requests to the service. How do I use curl to make authenticated (http basic) requests? Do I have to add the headers myself?
blank
  • 17,852
  • 20
  • 105
  • 159
295
votes
3 answers

'Best' practice for restful POST response

So nothing new here I am just trying to get some clarification and cannot seem to find any in other posts. I am creating a new resource restulfully, say: /books (POST) with a body: { title: 'The Lion, the Witch and the Wardrobe', author: 'C. S.…
lostintranslation
  • 23,756
  • 50
  • 159
  • 262
294
votes
12 answers

REST API 404: Bad URI, or Missing Resource?

I'm building a REST API, but I've encountered a problem. It seems that accepted practice in designing a REST API is that if the resource requested doesn't exist, a 404 is returned. However, to me, this adds unnecessary ambiguity. HTTP 404 is more…
Brian Lacy
  • 18,785
  • 10
  • 55
  • 73
294
votes
7 answers

How do I upload a file with metadata using a REST web service?

I have a REST web service that currently exposes this URL: http://server/data/media where users can POST the following JSON: { "Name": "Test", "Latitude": 12.59817, "Longitude": 52.12873 } in order to create a new Media metadata. Now I…
Daniel T.
  • 37,212
  • 36
  • 139
  • 206
285
votes
6 answers

Is it considered bad practice to perform HTTP POST without entity body?

I need to invoke a process which doesn't require any input from the user, just a trigger. I plan to use POST /uri without a body to trigger the process. I want to know if this is considered bad from both HTTP and REST perspectives?
Suresh Kumar
  • 11,241
  • 9
  • 44
  • 54
281
votes
14 answers

JAX-RS — How to return JSON and HTTP status code together?

I'm writing a REST web app (NetBeans 6.9, JAX-RS, TopLink Essentials) and trying to return JSON and HTTP status code. I have code ready and working that returns JSON when the HTTP GET method is called from the client.…
Meow
  • 18,371
  • 52
  • 136
  • 180
280
votes
15 answers

REST vs JSON-RPC?

I'm trying to chose between REST and JSON-RPC for developing an API for a web application. How do they compare? Update 2015: I have found REST easier to develop and use for an API which is served on Web/HTTP, because the existing and mature HTTP…
Ali Shakiba
  • 20,549
  • 18
  • 61
  • 88
278
votes
5 answers

Making a request to a RESTful API using Python

I have a RESTful API that I have exposed using an implementation of Elasticsearch on an EC2 instance to index a corpus of content. I can query the search by running the following from my terminal (MacOSX): curl -XGET…
user7289
  • 32,560
  • 28
  • 71
  • 88
273
votes
21 answers

file_get_contents(): SSL operation failed with code 1, Failed to enable crypto

I’ve been trying to access this particular REST service from a PHP page I’ve created on our server. I narrowed the problem down to these two lines. So my PHP page looks like this:
Joe
  • 8,251
  • 3
  • 18
  • 23
272
votes
17 answers

JavaScript/jQuery to download file via POST with JSON data

I have a jquery-based single-page webapp. It communicates with a RESTful web service via AJAX calls. I'm trying to accomplish the following: Submit a POST that contains JSON data to a REST url. If the request specifies a JSON response, then JSON…
Tauren
  • 26,795
  • 42
  • 131
  • 167
272
votes
4 answers

RESTful Authentication via Spring

Problem: We have a Spring MVC-based RESTful API which contains sensitive information. The API should be secured, however sending the user's credentials (user/pass combo) with each request is not desirable. Per REST guidelines (and internal business…
Chris Cashwell
  • 22,308
  • 13
  • 63
  • 94
271
votes
4 answers

REST API Best practices: args in query string vs in request body

A REST API can have arguments in several places: In the request body - As part of a json body, or other MIME type In the query string - e.g. /api/resource?p1=v1&p2=v2 As part of the URL-path - e.g. /api/resource/v1/v2 What are the best practices…
Jonathan Livni
  • 101,334
  • 104
  • 266
  • 359
271
votes
6 answers

Deciding between HttpClient and WebClient

Our web application is running in .NET Framework 4.0. The UI calls the controller methods through Ajax calls. We need to consume the REST service from our vendor. I am evaluating the best way to call the REST service in .NET 4.0. The REST service…
user3092913
  • 2,735
  • 2
  • 12
  • 4
262
votes
17 answers

How do you create a REST client for Java?

With JSR 311 and its implementations we have a powerful standard for exposing Java objects via REST. However on the client side there seems to be something missing that is comparable to Apache Axis for SOAP - something that hides the web service and…
Yaba
  • 5,979
  • 8
  • 38
  • 44
258
votes
11 answers

Main differences between SOAP and RESTful web services in Java

For now I have a slight idea about the differences between SOAP and RESTful services. My question is when I should use SOAP, and when I should use RESTful; which one is "better" when it comes to performance/speed or request handling? I'm…
Gandalf StormCrow
  • 25,788
  • 70
  • 174
  • 263