restful-architecture

How to add relationships in JAX-RS via RESTful web service?

删除回忆录丶 提交于 2019-12-11 23:52:43
问题 OK I can GET POST PUT DELETE simple resources (entities) in my RESTful web service ex. /rest/foos /rest/foos/1 /rest/bars /rest/bars/1 But how to handle adding relationships ex. @OneToMany, @ManyToMany between this relationships using RESTful web service. Suppose I have several Foo entities and several Bar entities how to establish relationships Bar 1 has Foo 3 , etc. I have such approach to GET this relationships: GET /rest/bars/1/foos Above returns collection of foos related with Bar(id=1)

RESTful - GET or POST - what to do?

大憨熊 提交于 2019-12-11 14:35:46
问题 Im working on a web service that i want to be RESTful. I know about the CRUD way of doing things, but I have a few things that im not completly clear with. So this is the case: I have a tracking service that collects some data in the browser (client) and then sends it off to the tracking server. There are 2 cases, one where the profile exists and one where it does not. Finally the service returns some elements that has to be injected to the DOM. So basically i need 2 web services: http:/

RESTful API best practices for admin and normal user access

眉间皱痕 提交于 2019-12-11 12:35:27
问题 Having to create a RESTful web service with admin and normal user access to resources (lets say cars), I would like to structure the Uri for the users as: http://myhost/users/5/cars/2 But as admin user, I would like to access all cars like: http://myhost/cars/51 Instead of the first I proposed, would you think that it's better to use just one Uri for cars, using filters for users, like: http://myhost/cars/?user=5 To don't have 2 different Uris for the same resource? Do you have other

Does using multipart/form-data Content Type for a RESTful POST api a good practice?

大憨熊 提交于 2019-12-11 11:56:13
问题 I have a situation where I have to write a api to create a resource and amongst datafields that I need to accept is a string that is basically contents of a html file. As I see it I have a choice between structuring the entire thing as a json object where this field is a string field with urlencoded html string , and having the Content Type as multipart/form-data where each of the fields and the html string (UTF-8 encoded) is a part in the message. Not using json is something I am not

Recursively intercepting $http

随声附和 提交于 2019-12-11 11:34:01
问题 In order to better consume a hateoas enabled rest api I got the idea to intercept http calls and add some methods to my resource objects before returning them. The idea is that if the resource has an array of links I'll add methods to easy further http requests. The below code is push to the interceptors array of a $httpProvider and does pretty much what I want. define(['angular'], function (angular) { var $http = angular.injector(['ng']).get('$http'); function flattenLinks(links) { for (var

MVC Rest and returning views

[亡魂溺海] 提交于 2019-12-11 07:59:26
问题 I'm trying to implement the restful convention on my controllers but am not sure how to handle failing model validation in sending it back to the 'New' view from the Create action. public class MyController : Controller { public ActionResult Index() { return View(); } public ActionResult New() { return View(); } [HttpPost] public ActionResult Create(MyModel model) { if(!ModelState.IsValid) { // Want to return view "new" but with existing model } // Process my model return RedirectToAction(

HTTP verbs - When to use GET/POST/PUT/Delete

允我心安 提交于 2019-12-11 02:50:02
问题 When you work on RESTFUL service you often hear the terms GET/POST/PUT/DELETE . My question is what is the idea behind so many verbs? I can achieve everything with the help of GET verb or if I want to post some large data in the body of the message, I can use POST verb. I do not think there is a need to think beyond these two verbs. Do we have any general guideline in terms of when to use which verb? Is there any advantage of using one verb over the other?? PS: I know the idea behind GET :

sending a json string in a http url

偶尔善良 提交于 2019-12-10 23:56:06
问题 I'm sending data from my Android app to my REST Service written as a asp.net web api. I am already successfully sending urls such as http://www.deanblakely.com/REST/api/products/3 and processing the params in the web.api. Now, in the Android client I have used GSON to convert a complex object to a json string and the string is as follows: [{"TStamp":"Sep 25, 2012 5:04:46 PM","emailaddress":"webapi@restserver.com","altitude":0.0,"latitude":3.3743984E7,"longitude":-1.18107841E8,"legnum":1}] How

video tag html5 with src from base64_encode not work on different device and browser

僤鯓⒐⒋嵵緔 提交于 2019-12-10 22:29:04
问题 i try this code. <video width="320" height="240" controls="controls" autobuffer="autobuffer"> <source src="data:video/mp4;base64,AAAA<?php echo chunk_split(base64_encode(trim(file_get_contents('kecak.mp4')))); ?>" type="video/mp4" /> Your browser does not support the video tag. </video> it's work when i play in Notebook(safari, firefox) but not work when i play on IPAD2(safari) or Samsung Galaxy(Opera). i think the problem is in src="data:video/mp4;base64,AAAA<?php echo chunk_split(base64

Is there some kind of service to queue api calls?

会有一股神秘感。 提交于 2019-12-10 15:29:03
问题 I need to call the desk.com api to create cases when a customer completes a form on my site. However sometimes the API is down for maintenance (too often!) and my call will fail. Presently I just write the details to a log on error and send myself an email. Then I create the case manually. So I'm thinking to write some kind of message queue so instead of calling the api in-process, I can put the request in queue, then have some process work the queue and make the api calls. they way if the