put

Consequences of POST not being idempotent (RESTful API)

守給你的承諾、 提交于 2019-12-02 15:33:32
I am wondering if my current approach makes sense or if there is a better way to do it. I have multiple situations where i want to create new objects and let the server assign an ID to those objects. Sending a POST request appears to be the most appropriate way to do that. However since POST is not idempotent the request may get lost and sending it again may create a second object. Also requests being lost might be quite common since the API is often accessed through mobile networks. As a result i decided to split the whole thing into a two-step process. First sending a POST request to create

X-HTTP-Method-Override in jQuery?

萝らか妹 提交于 2019-12-02 15:17:34
How can I do an X-HTTP-Method-Override for an ajax request in jQuery? scurker With 1.5 you can now pass in a headers option: $.ajax({ headers: { 'X-HTTP-Method-Override': 'DELETE' }, method: 'GET' // more parameters... }); This is set before 'beforeSend' is called, so it could still get overwritten. See http://api.jquery.com/jQuery.ajax/ -- fixed incorrect syntax (wouldn't let me save with less than 6 character edit, so writing this message You could set custom headers when performing an ajax request by using the beforeSend callback: $.ajax({ beforeSend: function(xhr) { xhr.setRequestHeader('X

What does “$x->Put” do in Perl?

元气小坏坏 提交于 2019-12-02 15:05:55
I am looking at this piece of code: $diag_cmd = pack("CCSV", DIAG_SUBSYS_CMD_F, DIAG_SUBSYS_PWRDB, PWRDB_DIAG_PKT_SCRIPT | $processor_select, length($s_part)) . $s_part; $diag_request_var = Variant(VT_ARRAY | VT_UI1, length $diag_cmd); $diag_request_var->Put($diag_cmd); where Variant is defined below: sub Variant { return Win32::OLE::Variant->new(@_); } I am not sure what does it do and what does PUT actually do in Perl. Any ideas? Put is not a standard function that comes with Perl. In this case, you have an object named $diag_request_var which is of class Win32::OLE::Variant . Put is a

Cross domain put call does not work with Access-Control-Allow-Origin

帅比萌擦擦* 提交于 2019-12-02 08:39:42
I am facing problem related to cross domain PUT call , i have allowed Access-Control-Allow-Origin from server side put still it doesn't work. @PUT @Path("/getresponse/{caller}") @Produces({MediaType.APPLICATION_JSON}) public Response getResponseData(@PathParam("caller") String caller ,@QueryParam("ticket")String ticket ,@FormParam("formParam") String data){ ResponseBuilder resp; System.out.println("name of caller is -> "+ caller); System.out.println("query param ticket -> "+ ticket); System.out.println("form param data->" + data); Employee emp = new Employee(); emp.setAge(23); emp.setName(

Is it possible to update an existing field in an index through mapping in Elasticsearch?

烈酒焚心 提交于 2019-12-02 08:37:28
I've already created an index, and it contains data from my MySQL database. I've got few fields which are string in my table, where I need them as different types ( integer & double ) in Elasticsearch . So I'm aware that I could do it through mapping as follows: { "mappings": { "my_type": { "properties": { "userid": { "type": "text", "fielddata": true }, "responsecode": { "type": "integer" }, "chargeamount": { "type": "double" } } } } } But I've tried this when I'm creating the index as a new one. What I wanted to know is how can I update an existing field (ie: chargeamount in this scenario)

PHP HTTP CURL PUT request for LIFX Power On/Off

谁说我不能喝 提交于 2019-12-02 07:43:21
I'm trying to power all of my Lifx bulbs on/off using PHP. The API documentation, http://developer.lifx.com/ , says to use a PUT request: curl -u "c87c73a896b554367fac61f71dd3656af8d93a525a4e87df5952c6078a89d192:" \ -X PUT \ -d "state=on" \ "https://api.lifx.com/v1beta1/lights/all/power" Now using that curl command works in the command line. It prompts me for my password unless I add it after the colon in the "username". The trouble is when I try to translate that command into PHP like so: $authToken = 'c87c73a896b554367fac61f71dd3656af8d93a525a4e87df5952c6078a89d192:myFakePassword'; $ch =

(CURL, PHP) Uploading files with PUT request, How do I process this?

只谈情不闲聊 提交于 2019-12-02 07:09:10
问题 this is what i have in process.php parse_str(file_get_contents("php://input"),$upload_data); if (isset($upload_data)) { print_r($upload_data); exit; } this is how i query to server using curl. weldan@prindu:~$ curl -X PUT -H "X-TOKEN: test123" -F filedata=@/home/weldan/Pictures/Cool-Pictures1.jpg http://host.tld/process.php Array ( [------------------------------22031b6e799c Content-Disposition:_form-data;_name] => "filedata"; filename="Cool-Pictures1.jpg" Content-Type: image/jpeg ��� ) so

How to send a PUT/DELETE request in jQuery?

眉间皱痕 提交于 2019-12-02 04:41:08
GET : $.get(..) POST : $.post().. What about PUT/DELETE ? You could use the ajax method: $.ajax({ url: '/script.cgi', type: 'DELETE', success: function(result) { // Do something with the result } }); $.ajax will work. $.ajax({ url: 'script.php', type: 'PUT', success: function(response) { //... } }); We can extend jQuery to make shortcuts for PUT and DELETE: jQuery.each( [ "put", "delete" ], function( i, method ) { jQuery[ method ] = function( url, data, callback, type ) { if ( jQuery.isFunction( data ) ) { type = type || callback; callback = data; data = undefined; } return jQuery.ajax({ url:

AngularJS - PUT method not working (404 error)

泄露秘密 提交于 2019-12-02 02:30:37
I'm new to AngularJS and I have trouble to update an object via REST. I'm using a PHP/Mysql Backend (Slim Framework). I'm able to retrieve (GET), create (POST) a new object but not to edit (PUT) one. Here's the code: my Form: <form name="actionForm" novalidate ng-submit="submitAction();"> Name: <input type="text" ng-model="action.name" name="name" required> <input type="submit"> </form> My service: var AppServices = angular.module('AppServices', ['ngResource']) AppServices.factory('appFactory', function($resource) { return $resource('/api/main/actions/:actionid', {}, { 'update': { method: 'PUT

SpringMVC控制器接收不了PUT提交的参数的解决方案

烈酒焚心 提交于 2019-12-01 18:45:28
这次改造了下框架,把控制器的API全部REST化,不做不知道,SpringMVC的REST有各种坑让你去跳,顺利绕过它们花了我不少时间,这次来提下SpringMVC的PUT提交参数为null的情况。 照常先贴出我的控制器代码,没什么特别的,就是打印出接受到的前台参数值: @RequestMapping(value = "/{id}", method = RequestMethod.PUT) @ResponseBody public Map<String, Object> update( @RequestParam(value = "isform", required = false) String isform, @PathVariable("id") String id) { System.out.println("id value: " + id); System.out.println("isform value: " + isform); return null; } 很常规的PUT控制器,用来修改原有的记录,原有的的web.xml中,我只添加了一个和REST涉及的过滤器 org.springframework.web.filter.HiddenHttpMethodFilter <filter> <filter-name>HttpMethodFilter</filter