put

Making a REST API request in PHP

空扰寡人 提交于 2019-12-04 13:58:09
Apologies for newbishness of this question. I'm looking into integrating one website's API into my own website. Here's some quotes from their documentation: At the moment we only support XML, when calling our API the HTTP Accept header content type must be set to “application/xml”. The API uses the PUT request method. I have the XML I want to send, and I have the URL I want to send it to, but how do I go about constructing a suitable HTTP Request in PHP that will also grab the XML that's returned? Thanks in advance. You can use file_get_contents and stream_context_create to create a request

PUT request to django tastypie resource not working

可紊 提交于 2019-12-04 10:23:02
i'm trying to do a put request to my django tastypie resource in order to update user info. Up to now, i can make post request but put is not working. In my api.py i have this: class UserResource(ModelResource): class Meta: queryset = User.objects.all() resource_name = 'auth/user' fields = ['username', 'email'] authentication = BasicAuthentication() authorization = DjangoAuthorization() filtering = { "username": ('exact',), } class UserSignUpResource(ModelResource): class Meta: object_class = User resource_name = 'register_user' fields = ['username', 'email' , 'password'] allowed_methods = [

How is the PUT request in this example using subresource is processed by JAX-RS run time?

ぐ巨炮叔叔 提交于 2019-12-04 09:07:34
I am reading through this example of Storage-service example in Jersey Sample provided in oracle docs. I am just unable to understand how this PUT request is resolved by JAX-RS runtime? curl -X PUT http://127.0.0.1:9998/storage/containers/quotes here is the code snippet that corresponds to this request (taken from above link). @Path("/containers") @Produces("application/xml") public class ContainersResource { @Context UriInfo uriInfo; @Context Request request; @Path("{container}") public ContainerResource getContainerResource(@PathParam("container") String container) { return new

PHP HTTP CURL PUT request for LIFX Power On/Off

旧时模样 提交于 2019-12-04 06:40:06
问题 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:

Unity: Use HTTP PUT in Unity3D

落花浮王杯 提交于 2019-12-04 06:26:27
I'm quite new to Unity and facing some problems about RESTFul in Unity. I want to update some data on the server by using HTTP PUT, but as what I received when search the web, the WWWW class in Unity doesn't support HTTP PUT. I also tried some HttpWebRequest example related to HTTP PUT but always received error code 400: Bad Request. How can I solve this problem? Do I have to list out all the key-value pairs when updating or just need to list the pairs I want to change the value ? If you're not looking for a 3rd party plugin and assuming your server supports it then one method you could look

Angular resource custom URL is using query strings and POST parameters

心不动则不痛 提交于 2019-12-04 04:46:05
I've written a custom method on an Angular resource in my application for activating a user. The API endpoint is /users/activate and an activation code must be PUTed to this endpoint. This is what my resource looks like: app.factory('User', ['$resource', function($resource){ return $resource('http://api.site.dev/users/:id', {id: '@id'}, { activate: {method:'PUT', params:{code: '@code'}, url: 'http://api.site.dev/users/activate'} }); }]); and I'm using it in my controller like so: User.activate({code: $routeParams.code}); As you can see from the network log on Chrome, the activation code is

python: HTTP PUT with unencoded binary data

人盡茶涼 提交于 2019-12-04 03:00:54
I cannot for the life of me figure out how to perform an HTTP PUT request with verbatim binary data in Python 2.7 with the standard Python libraries. I thought I could do it with urllib2, but that fails because urllib2.Request expects its data in application/x-www-form-urlencoded format. I do not want to encode the binary data, I just want to transmit it verbatim, after the headers that include Content-Type: application/octet-stream Content-Length: (whatever my binary data length is) This seems so simple, but I keep going round in circles and can't seem to figure out how. How can I do this?

RestTemplate usage

半世苍凉 提交于 2019-12-04 01:42:47
问题 I'm trying to use RestTemplate in order to make a PUT . For some reason I can't reproduce the PUT I created using curl that goes through without any problems. Here is my curl call that succeeds and returns 200: curl https://www.exampe.com \ -X PUT \ -H "Content-Type: application/json" \ -H "Authorization: Bearer <bearer-token>" \ -v \ -d '{"json":"object"}' And here is Java code that tried to replicate this curl call. This code in my case will throw HttpClientErrorException with status = 406:

POSIX error 12 (“Cannot allocate memory”) while uploading files from an iPhone

老子叫甜甜 提交于 2019-12-03 17:49:52
问题 I'm working on an iPhone application that involves uploading full photos from the camera (generally between 1.5 to 2.0 MB each) as well as their thumbnails (much smaller) to Amazon S3. The thumbnails always successfully upload, but sometimes the full images don't, and when they fail, they fail with POSIX error code 12, aka ENOMEM. However, I've added debug code to print the amount of free memory when the error happens, and there's always quite a bit free, usually more than 100 MB. Furthermore

How to implement a PUT call with JSON data using AJAX and JQuery?

。_饼干妹妹 提交于 2019-12-03 17:30:49
问题 I've looked around and tried many different methods, but can't seem to pass actual data to my controller's function. Here is some code: var URL = "/Timesheet/Timesheet/UpdateEntry"; var dataObject = { 'newWeekEntry': newEntry, 'oldWeekEntry': oldEntry }; alert(JSON.stringify(dataObject)); $.ajax({ url: URL, type: 'PUT', data: JSON.stringify(dataObject), dataType: 'json', success: function(result) { alert("success?"); } }); newEntry and oldEntry are both objects. The alert line outputs this