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
258
votes
6 answers

How to set an "Accept:" header on Spring RestTemplate request?

I want to set the value of the Accept: in a request I am making using Spring's RestTemplate. Here is my Spring request handling code @RequestMapping( value= "/uom_matrix_save_or_edit", method = RequestMethod.POST, …
edaklij
  • 4,121
  • 11
  • 31
  • 43
250
votes
7 answers

How to use the 'main' parameter in package.json?

I have done quite some search already. However, still having doubts about the 'main' parameter in the package.json of a Node project. How would filling in this field help? Asking in another way, can I start the module in a different style if this…
Gavin
  • 4,458
  • 3
  • 24
  • 37
249
votes
4 answers

Invoke-WebRequest, POST with parameters

I'm attempting to POST to a uri, and send the parameter username=me Invoke-WebRequest -Uri http://example.com/foobar -Method POST How do I pass the parameters using the method POST?
kylex
  • 14,178
  • 33
  • 114
  • 175
245
votes
11 answers

Transactions across REST microservices?

Let's say we have a User, Wallet REST microservices and an API gateway that glues things together. When Bob registers on our website, our API gateway needs to create a user through the User microservice and a wallet through the Wallet microservice.…
Olivier Lalonde
  • 19,423
  • 28
  • 76
  • 91
245
votes
8 answers

How to export specific request to file using postman?

I want to export one specific request from a Postman extension (Chromium) and send it to another developer so that they can import it. How I can do this?
Sild
  • 3,077
  • 3
  • 15
  • 21
240
votes
7 answers

How to POST JSON Data With PHP cURL?

Here is my code, $url = 'url_to_post'; $data = array( "first_name" => "First name", "last_name" => "last name", "email"=>"email@gmail.com", "addresses" => array ( "address1" => "some address", "city" => "city", …
user1463076
  • 2,715
  • 4
  • 16
  • 12
235
votes
6 answers

Security of REST authentication schemes

Background: I'm designing the authentication scheme for a REST web service. This doesn't "really" need to be secure (it's more of a personal project) but I want to make it as secure as possible as an exercise/learning experience. I don't want to use…
dF.
  • 74,139
  • 30
  • 130
  • 136
235
votes
4 answers

How to POST form data with Spring RestTemplate?

I want to convert the following (working) curl snippet to a RestTemplate call: curl -i -X POST -d "email=first.last@example.com" https://app.example.com/hr/email How do I pass the email parameter correctly? The following code results in a 404 Not…
sim
  • 3,552
  • 5
  • 23
  • 23
233
votes
13 answers

Proper way to set response status and JSON content in a REST API made with nodejs and express

I am playing around with Nodejs and express by building a small rest API. My question is, what is the good practice/best way to set the code status, as well as the response data? Let me explain with a little bit of code (I will not put the node and…
dukable
  • 3,968
  • 11
  • 31
  • 42
232
votes
11 answers

What is "406-Not Acceptable Response" in HTTP?

In my Ruby on Rails application I tried to upload an image through the POSTMAN REST client in Base64 format. When I POST the image I am getting a 406 Not Acceptable Response. When I checked my database, the image was there and was successfully…
Cyber
  • 4,844
  • 8
  • 41
  • 61
231
votes
11 answers

Restful API service

I'm looking to make a service which I can use to make calls to a web-based REST API. Basically I want to start a service on app init then I want to be able to ask that service to request a url and return the results. In the meantime I want to be…
Martyn
  • 16,432
  • 24
  • 71
  • 104
229
votes
11 answers

Best practice for partial updates in a RESTful service

I am writing a RESTful service for a customer management system and I am trying to find the best practice for updating records partially. For example, I want the caller to be able to read the full record with a GET request. But for updating it only…
magiconair
  • 6,659
  • 4
  • 29
  • 26
227
votes
9 answers

Which HTTP methods match up to which CRUD methods?

In RESTful style programming, we should use HTTP methods as our building blocks. I'm a little confused though which methods match up to the classic CRUD methods. GET/Read and DELETE/Delete are obvious enough. However, what is the difference between…
Drew
  • 15,158
  • 17
  • 68
  • 77
227
votes
11 answers

JAX-RS / Jersey how to customize error handling?

I'm learning JAX-RS (aka, JSR-311) using Jersey. I've successfuly created a Root Resource and am playing around with parameters: @Path("/hello") public class HelloWorldResource { @GET @Produces("text/html") public String get( …
Mark Renouf
  • 30,697
  • 19
  • 94
  • 123
227
votes
11 answers

Web service differences between REST and RPC

I have a web service that accepts JSON parameters and have specific URLs for methods, e.g.: http://IP:PORT/API/getAllData?p={JSON} This is definitely not REST as it is not stateless. It takes cookies into account and has its own session. Is it…
Mazmart
  • 2,703
  • 4
  • 17
  • 20