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
399
votes
12 answers

Call a REST API in PHP

Our client had given me a REST API to which I need to make a PHP call. But as a matter of fact, the documentation given with the API is very limited, so I don't really know how to call the service. I've tried to Google it, but the only thing that…
Michiel
  • 7,855
  • 16
  • 61
  • 113
396
votes
18 answers

Spring MVC @PathVariable with dot (.) is getting truncated

This is continuation of question Spring MVC @PathVariable getting truncated Spring forum states that it has fixed(3.2 version) as part of ContentNegotiationManager. see the below…
Kanagavelu Sugumar
  • 18,766
  • 20
  • 94
  • 101
393
votes
9 answers

How to get body of a POST in php?

I submit as POST to a php page the following: {a:1} This is the body of the request (a POST request). In php, what do I have to do to extract that value? var_dump($_POST); is not the solution, not working.
Itay Moav -Malimovka
  • 52,579
  • 61
  • 190
  • 278
391
votes
28 answers

SOAP or REST for Web Services?

Is REST a better approach to doing Web Services or is SOAP? Or are they different tools for different problems? Or is it a nuanced issue - that is, is one slightly better in certain arenas than another, etc? I would especially appreciate…
user13276
  • 4,873
  • 5
  • 21
  • 16
390
votes
9 answers

How do I send a JSON string in a POST request in Go

I tried working with Apiary and made a universal template to send JSON to mock server and have this code: package main import ( "encoding/json" "fmt" "github.com/jmcvetta/napping" "log" "net/http" ) func main() { url :=…
Ladislav Prskavec
  • 4,351
  • 3
  • 19
  • 16
383
votes
17 answers

Spring RestTemplate GET with parameters

I have to make a REST call that includes custom headers and query parameters. I set my HttpEntity with just the headers (no body), and I use the RestTemplate.exchange() method as follows: HttpHeaders headers = new…
Elwood
  • 4,451
  • 4
  • 18
  • 20
379
votes
10 answers

400 BAD request HTTP error code meaning?

I have a JSON request which I'm posting to a HTTP URL. Should this be treated as 400 where requestedResource field exists but "Roman" is an invalid value for this field? [{requestedResource:"Roman"}] Should this be treated as 400 where "blah"…
Phoenix
  • 8,695
  • 16
  • 55
  • 88
372
votes
18 answers

Separate REST JSON API server and client?

I'm about to create a bunch of web apps from scratch. (See http://50pop.com/code for overview.) I'd like for them to be able to be accessed from many different clients: front-end websites, smartphone apps, backend webservices, etc. So I really want…
sivers
  • 3,833
  • 3
  • 14
  • 7
367
votes
16 answers

No 'Access-Control-Allow-Origin' - Node / Apache Port Issue

i've created a small API using Node/Express and trying to pull data using Angularjs but as my html page is running under apache on localhost:8888 and node API is listen on port 3000, i am getting the No 'Access-Control-Allow-Origin'. I tried using …
user1336103
  • 3,789
  • 4
  • 16
  • 12
354
votes
12 answers

API pagination best practices

I'd love some some help handling a strange edge case with a paginated API I'm building. Like many APIs, this one paginates large results. If you query /foos, you'll get 100 results (i.e. foo #1-100), and a link to /foos?page=2 which should return…
2arrs2ells
  • 3,637
  • 3
  • 15
  • 12
352
votes
27 answers

How to POST raw whole JSON in the body of a Retrofit request?

This question may have been asked before but no it was not definitively answered. How exactly does one post raw whole JSON inside the body of a Retrofit request? See similar question here. Or is this answer correct that it must be form url encoded…
user3243335
  • 3,521
  • 3
  • 12
  • 4
350
votes
7 answers

How can I handle many-to-many relationships in a RESTful API?

Imagine you have two entities, Player and Team, where players can be on multiple teams. In my data model, I have a table for each entity, and a join table to maintain the relationships. Hibernate is fine at handling this, but how might I expose…
Richard Handworker
  • 3,579
  • 3
  • 15
  • 6
349
votes
25 answers

Is it possible to send an array with the Postman Chrome extension?

I've been using Postman Chrome extension to test out my API and would like to send an array of IDs via post. Is there a way to send something list this as a parameter in Postman? { user_ids: ["1234", "5678"] }
Will Hitchcock
  • 4,648
  • 3
  • 22
  • 32
349
votes
18 answers

When to use @QueryParam vs @PathParam

I am not asking the question that is already asked here: What is the difference between @PathParam and @QueryParam This is a "best practices" or convention question. When would you use @PathParam vs @QueryParam. What I can think of that the decision…
Blessed Geek
  • 21,058
  • 23
  • 106
  • 176
346
votes
14 answers

REST API Best practices: Where to put parameters?

A REST API can have parameters in at least two ways: As part of the URL-path (i.e. /api/resource/parametervalue ) As a query argument (i.e. /api/resource?parameter=value ) What is the best practice here? Are there any general guidelines when to…
Kalle Gustafsson
  • 3,503
  • 3
  • 15
  • 8