Questions tagged [restful-url]

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

https://en.wikipedia.org/wiki/Representational_state_transfer

1351 questions
38
votes
4 answers

Restful URLs with data in query string or request body?

What's the rule of thumb for passing data in a REST URL in the query string vs. the body of a request? Ie: You're creating a service to add hockey players. You could go with: PUT /players { "name": Gretzky } or PUT /players?name=Gretzky If…
Marcus Leon
  • 55,199
  • 118
  • 297
  • 429
38
votes
4 answers

How to handle hierarchical routes in ASP.NET Web API?

Currently I have two controllers 1 - Parent Controller 2 - Child Controller I access my Parent Controller like this someurl\parentcontroller Now I want to access my children controller like this someurl\parentcontroller\1\childcontroller This…
Haris Hasan
  • 29,856
  • 10
  • 92
  • 122
32
votes
4 answers

RESTful API - Designing sub-resources

I am designing a RESTful API and I came up with a problem related to sub-resources. I see other APIs using full URL to operate over sub-resources. Take the example where Company has Departments and Department has Employees. In the beginning I though…
Rafa
  • 1,997
  • 3
  • 21
  • 33
29
votes
4 answers

RESTful API routes design: nested vs. non-nested

My question is about the advantages of nesting resources when building URLs for API purposes. Consider the following two alternatives for accessing an employee resource: /api/employees?department=1 # flat Vs. /api/departments/1/employees #…
Ernesto
  • 3,837
  • 6
  • 35
  • 56
27
votes
3 answers

Is using magic (me/self) resource identifiers going against REST principles?

I've seen URIs that support magic ids for the authenticated user like below: GET /user/me - list my profile GET /user/me/photos - list my photos where the ones below use the actual user id GET /user/742924 GET /user/742924/photos The problem I see…
Emanuel George Hategan
  • 1,123
  • 1
  • 13
  • 22
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
23
votes
1 answer

How to loop through paginated API using python

I need to retrieve the 500 most popular films from a REST API, but the results are limited to 20 per page and I am only able to make 40 calls every 10 seconds (https://developers.themoviedb.org/3/getting-started/request-rate-limiting). I am unable…
izzy84
  • 249
  • 1
  • 2
  • 7
22
votes
2 answers

How do I get started with swagger-ui

What is swagger-ui and what is the use of it? I have visited http://swagger.io/, but I need more information. Please guide me.
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
4 answers

Is an API endpoint that differentiates what resources to return based on user credentials RESTful and good URI design?

Important note The focus of this question is on API endpoints that differentiate which resources are returned depending who authenticates, e.g. Alice gets resource A and B returned, and Bob gets resource X and Y. It is NOT about differentiating…
Visionscaper
  • 3,979
  • 1
  • 23
  • 26
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
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
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…
16
votes
3 answers

HTTP POST response Location header when creating multiple resources

The HTTP/1.1 standard states that if a POST operation results in the creation of a resource, then the response should include a Location header with the address of the new resource. If a resource has been created on the origin server, the response …
metacubed
  • 7,031
  • 6
  • 36
  • 65
1
2
3
90 91