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
346
votes
40 answers

"SyntaxError: Unexpected token < in JSON at position 0"

In a React app component which handles Facebook-like content feeds, I am running into an error: Feed.js:94 undefined "parsererror" "SyntaxError: Unexpected token < in JSON at position 0 I ran into a similar error which turned out to be a typo in…
Cameron Sima
  • 5,086
  • 6
  • 28
  • 47
346
votes
5 answers

Postman Chrome: What is the difference between form-data, x-www-form-urlencoded and raw

I am using the Postman Chrome extension for testing a web service. There are three options available for data input. I guess the raw is for sending JSON. What is the difference between the other two, form-data and x-www-form-urlencoded?
Rohan
  • 13,308
  • 21
  • 81
  • 154
343
votes
13 answers

Pagination in a REST web application

This is a more generic reformulation of this question (with the elimination of the Rails specific parts) I am not sure how to implement pagination on a resource in a RESTful web application. Assuming that I have a resource called products, which of…
andi
  • 14,322
  • 9
  • 47
  • 46
342
votes
6 answers

Should I use PATCH or PUT in my REST API?

I want to design my rest endpoint with the appropriate method for the following scenario. There is a group. Each group has a status. The group can be activated or inactivated by the admin. Should I design my end point as PUT…
java_geek
  • 17,585
  • 30
  • 91
  • 113
340
votes
4 answers

REST API - file (ie images) processing - best practices

We are developing server with REST API, which accepts and responses with JSON. The problem is, if you need to upload images from client to server. Note: and also I am talking about a use-case where the entity (user) can have multiple files…
libik
  • 22,239
  • 9
  • 44
  • 87
338
votes
4 answers

REST response code for invalid data

What response code should be passed to client in case of following scenarios? Invalid data passed while user registration like wrong email format User name/ Email is already exists I chose 403. I also found following that I feel can be…
Amit Patel
  • 15,609
  • 18
  • 68
  • 106
336
votes
2 answers

InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately

Tried to perform REST GET through python requests with the following code and I got error. Code snip: import requests header = {'Authorization': 'Bearer...'} url = az_base_url + az_subscription_id + '/resourcegroups/Default-Networking/resources?' +…
user4525298
  • 3,369
  • 3
  • 11
  • 3
328
votes
6 answers

How do I set a cookie on HttpClient's HttpRequestMessage

I am trying to use the web api's HttpClient to do a post to an endpoint that requires login in the form of an HTTP cookie that identifies an account (this is only something that is #ifdef'ed out of the release version). How do I add a cookie to the…
George Mauer
  • 117,483
  • 131
  • 382
  • 612
322
votes
37 answers

How to enable CORS in ASP.net Core WebAPI

What I am trying to do I have a backend ASP.Net Core Web API hosted on an Azure Free Plan (Add default security headers in .Net Core). I also have a Client Website which I want to make consume that API. The Client Application will not be hosted on…
killerrin
  • 3,367
  • 3
  • 13
  • 9
321
votes
16 answers

Recommendations of Python REST (web services) framework?

Is there a list somewhere of recommendations of different Python-based REST frameworks for use on the serverside to write your own RESTful APIs? Preferably with pros and cons. Please feel free to add recommendations here. :)
darius
  • 4,967
  • 4
  • 27
  • 18
318
votes
5 answers

How to download excel (.xls) file from API in postman?

I have an API endpoint and an Authorization token for that API. The said API is for .xls report download. How can I view the downloaded .xls file using (if possible) Postman? If it is not possible using Postman what are the other programmatic ways I…
axnet
  • 5,146
  • 3
  • 25
  • 45
309
votes
18 answers

Sending the bearer token with axios

In my react app i am using axios to perform the REST api requests. But it's unable to send the Authorization header with the request. Here is my code: tokenPayload() { let config = { headers: { 'Authorization': 'Bearer ' + validToken() …
rakibtg
  • 5,521
  • 11
  • 50
  • 73
299
votes
3 answers

What's the difference between "Request Payload" vs "Form Data" as seen in Chrome dev tools Network tab

I have an old web application I have to support (which I did not write). When I fill out a form and submit then check the "Network" tab in Chrome I see "Request Payload" where I would normally see "Form Data". What is the difference between the two…
red888
  • 27,709
  • 55
  • 204
  • 392
299
votes
9 answers

How to create REST URLs without verbs?

I'm struggling to determine how to design restful URLs. I'm all for the restful approach of using URLs with nouns and not verbs don't understand how to do this. We are creating a service to implement a financial calculator. The calculator takes a…
Marcus Leon
  • 55,199
  • 118
  • 297
  • 429
298
votes
10 answers

How to call a REST web service API from JavaScript?

I have an HTML page with a button on it. When I click on that button, I need to call a REST Web Service API. I tried searching online everywhere. No clue whatsoever. Can someone give me a lead/Headstart on this? Very much appreciated.
Shaik Syed Ali
  • 3,359
  • 3
  • 17
  • 22