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
21
votes
2 answers

Jersey Client / JAX-RS and optional (not default) @QueryParam (client side)

I have a RESTful API who's document says that a certain query parameter is optional, and does not supply a default argument. So, I can either supply the value or not send it in the GET request as a parameter. Example: queryA is required queryB is…
justderb
  • 2,835
  • 1
  • 25
  • 38
21
votes
4 answers

How to configure Spring HATEOAS behind proxy?

I have Spring Data Rest with Hateoas as my backed. It is behind a proxy. Backend url: backend.com Proxy url: proxy.com When I query proxy url, e.g. http://proxy.com/items/1, I get a response with href links with domain backend.com. I need the domain…
Jan Święcki
  • 1,611
  • 2
  • 16
  • 28
21
votes
1 answer

How can I make url path in Swashbuckle/Swaggerwork when api is served from inside another project?

all. I am trying to document a WebApi 2 using Swashbuckle package. All works great if the API is running by itself i.e. localhost/api/swagger brings me to ui and localhost/api/swagger/docs/v1 to json. However the producation app initializes this…
Dmitriy
  • 638
  • 1
  • 6
  • 12
21
votes
2 answers

Gmail REST API : 400 Bad Request + Failed Precondition

I'm trying to send mails based on Gmail REST API using google java api services. I have configured through Google Develover Console an application client and downloaded p12 and json files. I have used this sample programs,…
Azimuts
  • 1,212
  • 4
  • 16
  • 35
21
votes
4 answers

django rest framework lookup_field through OneToOneField

https://gist.github.com/ranman/3d97ea9054c984bca75e Desired Behavior User lookup happens by the username: /api/users/randall Speaker lookup happens by the username as well: /api/speakers/randall Constraints Not all users are speakers. All speakers…
Randall Hunt
  • 12,132
  • 6
  • 32
  • 42
21
votes
6 answers

Yii2: How do change Pagination-Per-Page into RESTful Web Service API?

I am developing an application using AngularJS for the frontend and Yii2 for the backend. The frontend requires a comprehensive array of all users. In the documentation of Yii2, http://www.yiiframework.com/doc-2.0/guide-rest-quick-start.html I can…
Janka
  • 1,908
  • 5
  • 20
  • 41
21
votes
2 answers

Spring Boot customize http error response?

How can I customize the response status code and the data in the response body if an exception occurs in a Spring Boot web application? I have created a web app that throws a custom exception if something unexpected occurs due to some bad internal…
matsev
  • 32,104
  • 16
  • 121
  • 156
21
votes
2 answers

Do I violate RESTfulness when using POST as UPDATE OR CREATE

Given the requirement other departments have for our REST API they would like to use POST not just for CREATE but for UPDATE OR CREATE. I know in a RESTful API PUT could or should be used for that, but because clients have to update information that…
Robert
  • 1,286
  • 1
  • 17
  • 37
21
votes
4 answers

How to configure Spring Data REST to return the representation of the resource created for a POST request?

I am following the spring-data-rest guide Accessing JPA Data with REST. When I http post a new record it is inserted (and the response is a 201). That is great, but is there a way to configure the REST MVC code to return the newly created object?…
Mark.ewd
  • 694
  • 1
  • 8
  • 22
21
votes
2 answers

Jersey - Redirect after POST to outside URL

I'm using Jersey to create REST API. I have one POST method and as a response from that method, the user should be redirected to a custom URL like http://example.com that doesn't have to be related to API. I was looking at other similar questions on…
Vuk Stanković
  • 7,864
  • 10
  • 41
  • 65
21
votes
7 answers

REST verbs - which convention is "correct"

I'm well into implementing a REST service (on a Windows CE platform if that matters) and I started out using IBM's general definitions of using POST for creating (INSERTs) and PUT for updating. Now I've run across Sun's definitions which are…
ctacke
  • 66,480
  • 18
  • 94
  • 155
21
votes
4 answers

AngularJS best practice REST / CRUD

What is the best practice of doing CRUD operations via REST with AngularJS? Specially what is the Angular-Way here. By this I mean the way using the least code and the most default angular settings to achive this. I know $resource and it's default…
Scheintod
  • 7,953
  • 9
  • 42
  • 61
21
votes
12 answers

toResponse in jersey ExceptionMapper does not get invoked

So I'm building a web application, we are using JPA and Jersey to consume/produces JSON data. I have a custom "EntityException" aswell as a custom "EntityExceptionMapper" Here's the mapper: @Provider public class EntityExceptionMapper implements…
alex
  • 343
  • 1
  • 2
  • 8
21
votes
1 answer

How do I write unit tests for a REST API built in Slim Framework?

I have an API built in Slim like this: $app->group('/'.$endpoint, function () use ($app, $endpoint) { $handler = Api\Rest\Handlers\Factory::load($endpoint); if (is_null($handler)) { throw new \Exception('No REST…
bcmcfc
  • 25,966
  • 29
  • 109
  • 181
21
votes
4 answers

Using django-rest-interface

I have a django application that I'd like to add some rest interfaces to. I've seen http://code.google.com/p/django-rest-interface/ but it seems to be pretty simplistic. For instance it doesn't seem to have a way of enforcing security. How would…
Sam Corder
  • 5,374
  • 3
  • 25
  • 30