restful-url

Simple REST URL scheme

你。 提交于 2019-12-06 00:33:39
In my web app I've got a user model and a journal and post model. Each user can have multiple journals, each journal can have multiple posts. Is below the best way to represent this in a RESTful way? /profiles/<username> /profiles/<username>/journals/<journal_id> /profiles/<username>/journals/<journal_id>/posts/<post_id> or would: /profiles/<username> /journals/<journal_id> be a better way to go? Ming Chan You have three types of resources: Profiles, Journals, and Posts. If your business needs is to allow end-users to have access to them all, you will need to provide PUT/POST/GET/DELETE CRUD

getting 403 forbidden error [duplicate]

社会主义新天地 提交于 2019-12-05 21:07:43
This question already has answers here : 403 Forbidden with Java but not web browser? (4 answers) Closed last year . Getting 403 forbidden for below code, though " https://jsonplaceholder.typicode.com/posts/1 " works in postman @ComponentScan @EnableAutoConfiguration public class Application { public static void main(String[] args) { RestTemplate rt = new RestTemplate(); HttpHeaders headers = new HttpHeaders(); headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON)); HttpEntity<String> entity = new HttpEntity<String>("parameters", headers); String url = "https://jsonplaceholder.typicode

Laravel 4: how to write the correct nested controller for nested resource?

十年热恋 提交于 2019-12-05 19:37:56
In Laravel 4, I wish to create a set of restful resources as follows: http://localhost/posts/1/comments http://localhost/posts/1/comments/1 http://localhost/posts/1/comments/1/edit ... So I created two controllers: PostsController and CommentsController (on the same layer), and the routes are written as below: Route::resource('posts', 'PostsController'); Route::resource('posts.comments', 'CommentsController'); I also created a link in /views/comments/index.blade.php referring to routes: posts.comments.create {{ link_to_route('posts.comments.create', 'Add new comment') }} Here's the problem I

What's a RESTful way to query with logic operation?

夙愿已清 提交于 2019-12-05 17:42:28
This is a spin-off question to query with filters Say my application is managing objects called workload, with the following fields. I want to expose a REST interface for user to query workloads by labels. "Workload": {"id":"test1", "labels":["A", "B", "C"]} "Workload": {"id":"test2", "labels":["A", "C", "D"]} "Workload": {"id":"test3", "labels":["A", "B", "D"]} Question : How do I design the REST endpoint so that it would support query workload with basic logic operations? Sample Query 2 : I want to GET all the workloads with label "A" or "B" but no "C" No clue how to do this sort of rest api

Best design practice to implement routes and controllers for a RESTFul Laravel app

三世轮回 提交于 2019-12-05 13:23:27
I am developing an application with Laravel 5.2, it has to be implemented RESTFUL. It is also very easy to implement RESTful resources in Laravel. for example for getting all categories in json format in routes we just have to add Route::resource('category', 'CategoryController'); and then in the CategoryController we are going to have this for returning a JSON object of all categories: class CategoryController extends Controller public function index() { $categories = Category::all(); return view('category.index', ['categories' => $categories]); } the the mydomain.com\category will be mapped

how to specify a range of data or multiple entities in a restful web-service

ぐ巨炮叔叔 提交于 2019-12-05 13:02:35
To access an instance of a User in a restful web-service the url is structured as shown in the curl request below: curl -v -X GET -s "$BASE_URL/User/${customer_id}.json" If I wanted to specify all User entities or page through a range of User entities, such as the first 50 Users in my database, how would I structure my request so that it is compliant with REST ??? You should start by trying to de-emphasize the meaning of the characters in a URI. While nice, pretty and readable URIs are a good thing, they have nothing to do with REST -- in fact it's a good exercise to judge the design of a

the request sent by the client was syntactically incorrect when sending post requests

筅森魡賤 提交于 2019-12-05 09:55:01
The method in myController looks like this @RequestMapping(value="/{processId}/dependents", method=RequestMethod.POST,consumes="application/json") @ResponseBody public Dependents postdependent(@ModelAttribute ProcessContext process,@RequestBody Dependent dependent) { return process.getDependents().addDependent(dependent); } My gets and delete work perfectly. But whenever I do a post I am getting the request sent by the client was syntactically incorrect. JSON for post request: "{ 'dependentId' : '1003', 'firstName' : 'Vishu', 'lastName' : 'poodari', 'birthDate' : '1970/04/15' }" Please I tried

Best practices on using URIs as parameter value in REST calls

守給你的承諾、 提交于 2019-12-05 05:49:31
I am designing a REST API where some resources can be filtered through query parameters. In some cases, these filter values would be resources from the same REST API. This makes for longish and pretty unreadable URIs. While this is not too much of a problem in itself because the URIs are meant to be created and manipulated programmatically, it makes for some painful debugging. I was thinking of allowing shortcuts to URIs used as filter values and I wonder if this is allowed according to the REST architecture and if there are any best practices. For example: I have a resource that gets me Java

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

爱⌒轻易说出口 提交于 2019-12-05 00:27:28
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 the representation of resources returned. All the endpoints return JSON representations of resources. Preface Please consider the following three potential API endpoint designs, all returning thing resources of a user. Endpoint A GET /things If authentication credentials for <user_x> are provided with the request, it returns thing resources that

How to run a Selenium test from remote computers

隐身守侯 提交于 2019-12-04 21:04:28
I have written a test for a website with Selenium, now my coworkers ask me to share it on our internet so that they can have access to the test, what they want is to enter a URL on their broswer and my application starts and opens the test on their computers. I have used RESTFUL but I have two issues: 1) When I use my computer IP instead of "localhost" server = HttpServerFactory.create("http://198.53.63.200:9998/"); it does not work, I mean it does not work even on my own computer 2) I do not know that if I get it work on other computers will it open the test browser on theirs or on mine