restful-url

Passing array in GET for a REST call

时光怂恿深爱的人放手 提交于 2019-11-28 20:04:28
I have a url to fetch appointments for a user like this: /user/:userId/appointments How should the url look like if I want to get appointments for multiple users? should it be: /appointments?users=1d1,1d2.. Thanks, Chris. Collections are a resource so /appointments is fine as the resource. Collections also typically offer filters via the querystring which is essentially what users=id1,id2... is. So, /appointments?users=id1,id2 is fine as a filtered RESTful resource. I think it's a better practice to serialize your REST call parameters, usually by JSON-encoding them: /appointments?users=[id1

Confusion Between Noun vs. Verb in Rest URLs

与世无争的帅哥 提交于 2019-11-28 16:23:12
I have studied over the internet about restful APIs that it focuses on nouns not verbs in the url pattern, but now I am seeing multiple links that use verbs in the URL. Here is an example. POST /v1/payments/authorization/<Authorization-Id>/capture POST /v1/payments/authorization/<Authorization-Id>/void POST /v1/payments/authorization/<Authorization-Id>/reauthorize this is Paypal apis. PayPal API also on wikipedia on HTATEOAS page they gave a example ; <?xml version="1.0"?> <account> <account_number>12345</account_number> <balance currency="usd">100.00</balance> <link rel="deposit" href="

Hyphen, underscore, or camelCase as word delimiter in URIs?

余生长醉 提交于 2019-11-28 14:55:10
I'm designing an HTTP-based API for an intranet app. I realize it's a pretty small concern in the grand scheme of things, but: should I use hyphens, underscores, or camelCase to delimit words in the URIs? Here are my initial thoughts: camelCase possible issues if server is case-insensitive seems to have fairly widespread use in query string keys ( http://api.example.com ? searchQuery =...), but not in other URI parts Hyphen more aesthetically pleasing than the other alternatives seems to be widely used in the path portion of the URI never seen hyphenated query string key in the wild possibly

RESTfully design /login or /register resources?

你。 提交于 2019-11-28 13:11:23
问题 I was designing a web app and then stopped to think about how my api should be designed as a RESTful web service. For now, most of my URI's are generic and might apply to various web apps: GET /logout // destroys session and redirects to / GET /login // gets the webpage that has the login form POST /login // authenticates credentials against database and either redirects home with a new session or redirects back to /login GET /register // gets the webpage that has the registration form POST

PUT and POST getting 405 Method Not Allowed Error for Restful Web Services

房东的猫 提交于 2019-11-28 09:13:42
I am trying to set up a simple Restful Web-Service which returns either JSON or XML according to the Accept header. I am using Spring, Maven and WebLogic Server. I took the example from this post http://software.sawano.se/2012/03/combining-json-and-xml-in-restful-web.html and tried to improve on it. GET and DELETE is working for both JSON and XML.But PUT and POST gives a "405 Method Not Allowed" Error. I am trying to test this with the Chrome Extension Advanced Rest Client. below is the Response headers. Status 405 Method Not Allowed Show explanation Loading time: 327 Request headers Accept:

URL design for an API

杀马特。学长 韩版系。学妹 提交于 2019-11-28 06:36:37
I'm working on a private apis for our backend. I have collections that have associations. Each collection can be requested, paginated, you can also ask for the associations and paginate this associations. We're not sure about which URL design to use ... we're thinking about : /users.json?per_page=10&association=parts,auditions&parts_per_page=5&auditions_per_page=5 /users.json?per_page=10&association[]=parts&association[]=auditions&parts_per_page=5&auditions_per_page=10 /users.json?per_page=10&association[auditions]=true&association[parts][per_page]=5 What do you think ? which one would you

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

和自甴很熟 提交于 2019-11-28 06:30:46
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 is that the same resource id points to a different resource depending on the authenticated user. Is this going against any REST principles? Using /me to name a resource that corresponds to the authenticated user is perfectly fine from a REST perspective. According to Roy Thomas Fielding's dissertation, any information that can be named can be a

Log restful endpoints on container startup in a Spring application

这一生的挚爱 提交于 2019-11-28 05:00:11
问题 I've a Spring application that expose restful endpoints through @RequestMapping annotation in Controller classes. I wish that were logged into the console, at server startup, all the endpoints of all the application's controller. I use a tomcat server and log4j for logging. Thanks. 回答1: For those who use spring-boot: In the latest spring-boot release (since v2.1), they changed the mapping default log level (as specified in the Release Notes here). Add one of the following properties to

Why does including an action verb in the URI in a REST implementation violate the protocol?

大城市里の小女人 提交于 2019-11-28 03:23:36
问题 I'm finding it necessary to understand why including action verbs in the URI violates the REST protocol for URI syntax? When I read the following article, I sense that too many people are making too much noise about verbs, and that they should be making more noise about content types: RestWiki: Minimum Methods In a perfect world, client browsers would all support GET, POST, PUT and DELETE for request operations. However, only GET and POST are supported, which means we're stuck trying to

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

时间秒杀一切 提交于 2019-11-28 03:15:53
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 last url should return all the children of a particular parent. I have this route currently in my global.asax file routes.MapHttpRoute ("Route1", "{controller}/{id}", new { id = RouteParameter.Optional }); I am not sure how can I achieve my parent\id\child hierarchy.. How should I configure my routes to achieve this? Ideas? Configure the routes as below.