Questions tagged [restful-architecture]

RESTful, or representational state transfer, is a style of software architecture for distributed hypermedia systems such as the World Wide Web.

Representational state transfer (REST) is a style of software architecture for distributed hypermedia systems such as the World Wide Web.

REST attempts to describe architectures that use HTTP or similar protocols by constraining the interface to a set of well-known, standard operations (like GET, POST, PUT, DELETE for HTTP). Here, the focus is on interacting with stateless resources, rather than messages or operations.

1187 questions
30
votes
2 answers

REST - When to use 400 ("Bad Request")

I have a resource like this sales/customers/{customerno}. If a client sends a PUT request to this resource I would return 400 - Bad request if the xml in the entity body is not valid xml. But what if the xml is valid, but the content of the xml is…
28
votes
2 answers

Questions About Consuming Your Own API with OAuth

I'm building a RESTful API for a project I'm working on and I'd like to make the main application consume the API because: It will result in having one set of code to maintain Should we decide to expose the API for 3rd party devs it will already be…
Steve
  • 1,112
  • 8
  • 12
26
votes
6 answers

What are the best practices for the root page of a REST API?

I would like to know if there is some best practices about the root endpoint for a REST web service? I mean, should it be a short documentation about the usage of the API itself? Should it be an XML document describing all methods available? Should…
adam
  • 2,830
  • 5
  • 31
  • 37
25
votes
3 answers

Rails routing: resources with only custom actions

I have a NotificationsController, in which I only have the action clear. I'd like to access this action by doing POST /notifications/clear So I wrote this in my router: resources :notifications, :only => [] do collection do post :clear …
24
votes
4 answers

RESTful API without ID in the URL

I have been discussing the best way of doing this with one of my colleagues Here's an example scenario: I'm trying to GET all orders for a Customer with ID of 1234. Consider the following endpoint: /customer/orders With a GET request, with the…
24
votes
2 answers

How to structure REST resource hierarchy?

I'm new to server side web development and recently I've been reading a lot about implementing RESTful API's. One aspect of REST API's that I'm still stuck on is how to go about structuring the URI hierarchy that identifies resources that the client…
martega
  • 2,103
  • 2
  • 21
  • 33
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
20
votes
2 answers

Is it okay to use same resource name for both get and post rest api

Sometime back I developed a Restful service in Java with only 1 GET resource. It was accessed like this: GET http://localhost:8080/my-project/customers/transactions This GET request returns all the customer transactions. Now, I have another project…
Charu Khurana
  • 4,511
  • 8
  • 47
  • 81
19
votes
3 answers

Identity Server(OAuth2) implementation with integration to legacy systems(Forms Auth, ADFS,AD)

We are currently building a RESTful API(.Net Core, IdentityServer 4, EF6). We have released an MVP version of it. It also references a WCF service. This WCF service orchestrates all other calls to other internal (Legacy systems) and other…
19
votes
6 answers

Return the List returned by ResponseEntity

My REST client uses RestTemplate to obtain a List of objects. ResponseEntitiy res = restTemplate.postForEntity(getUrl(), myDTO, List.class); Now I want to use the list returned and return it as List to the calling class. In case of string,…
ND_27
  • 764
  • 3
  • 8
  • 26
18
votes
1 answer

What's a proper response status code to REST POST request when duplicate is found?

In my RESTful API client might try to post information that is already in the database, this is not an error, rather something client can ignore, maybe notify the user about already existing dublicate. Now i'm returning 409 Conflict and already…
miceuz
  • 3,327
  • 5
  • 29
  • 33
18
votes
3 answers

Is passing the tenant in a custom HTTP header RESTful?

I'm considering the following two ways of identifying the tenant of a HTTP request, in a multi-tenant environment - hardcoding the tenant in the URI: /{tenantUuid}/foos/{id} Or passing the tenant in a custom HTTP Header, such as: X-Auth-Token:…
Eugen
  • 8,523
  • 8
  • 52
  • 74
17
votes
1 answer

Is it necessary to build a separate API endpoint for mobile apps to access a Rails web app?

I have a web app implemented in Ruby on Rails 4, need an Android native app for it, I am really new to mobile development. I am a bit confused as to what the mobile-web architecture should look like in this case. I've done some research online,…
17
votes
2 answers

Laravel 4 as RESTful backend for AngularJS

I am trying to build a web application which should use Laravel as a RESTful backend API and AngularJS on client side. I read all the other post on Stackoverflow about the issue, but no one is definitely answering my doubts, at least, I did not find…
Matteo Piazza
  • 2,462
  • 7
  • 29
  • 38
17
votes
2 answers

Accessing versions/revisions of an object in a RESTful API

While designing a RESTful API we came across the problem of how to access different versions of the "same object". Let us say a page object is identified by a unique key and accessed by GET /api/page/pagekey. It can be updated by sending PUT…
1
2
3
79 80