put

How to retrieve the JSON message body in JAX-RS REST method?

百般思念 提交于 2019-12-06 11:56:26
I have the following JSON that will be passed as part of a HTTP request, in the message body. { "names": [ { "id":"<number>", "name":"<string>", "type":"<string>", } ] } My current REST handler is below. I am able to get the Id and `Version that is passed in as path params, but I am not sure how to retrieve the contents on the message body ? @PUT @Path("/Id/{Id}/version/{version}/addPerson") public Response addPerson(@PathParam("Id") String Id, @PathParam("version") String version) { if (isNull(Id) || isEmpty(version)) { return ResponseBuilder.badRequest().build(); } //HOW TO RECIEVE MESSAGE

IOS RESTKIT HTTP PUT example

空扰寡人 提交于 2019-12-06 10:51:10
问题 I want to update data in server which runs in REST API. i am using RESTKIT from ios device. But i could not find how to use PUT in restkit. I have to send data like key:"user_id" value:"2" these format. Can anyone please help me to solve this problem.. :( 回答1: SOKeyValue.h : serialized object used as parameter for your call. #import <Foundation/Foundation.h> @interface SOKeyValue : NSObject @property (nonatomic, retain) NSString* key; @property (nonatomic, retain) NSString* value; @end Here's

PUT request to django tastypie resource not working

可紊 提交于 2019-12-06 05:57:48
问题 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 =

E11000 duplicate key error when doing PUT for modifiable resource with Spring Data Rest

不羁的心 提交于 2019-12-06 05:53:41
Update: According to this question, the author of Spring data rest say, the @Version properties will become ETags in response header. And there are two options for update: Just PUT without an If-Match header -- enforces overriding whatever is present on the server as the aggregate gets loaded, incoming data mapped onto it and it written back. You still get optimistic locking applied if another client changed the aggregate in the meantime (although an admittedly very short window). If that's the case you'll see a 409 Conflict. I am currently using this way for PUT, and a 409 conflict is what I

Handling a POST request with libmicrohttpd

无人久伴 提交于 2019-12-06 05:35:41
I've to use libmicrohttpd to set up a REST server. There is no problem with the GET request, but I don't understand what I'm doing wrong to handle POST (PUT actually) request (JSON format). Here is the code : int MHD_answer_to_connection (void* cls, struct MHD_Connection* connection, const char* url, const char* method, const char* version, const char* upload_data, size_t* upload_data_size, void** con_cls) { // Initializes parser/camera/settings... static Parser parser; // The first time only the headers are valid, do not respond in the first round static int dummy; if (*con_cls != &dummy) {

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

浪子不回头ぞ 提交于 2019-12-06 05:06:19
问题 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

Boto DynamoDB2 conditional put_item

可紊 提交于 2019-12-06 04:35:53
问题 I am trying to have put_item to check if there is item with the same HashKey before actually adding the new item. According to boto DynamoDB2 document, it is possible to do it with "Conditional Put". I tried following command but no luck. connection.put_item('table',item={'locationId':'a1', 'timestamp': time.time()}, expected={'locationID':False}) The error message is as following. boto.exception.JSONResponseError: JSONResponseError: 400 Bad Request {u'Message': u'Expected null', u'__type': u

How to Consume JSON as input in PUT and POST method of REST webservice in java

孤街浪徒 提交于 2019-12-05 22:10:31
I am trying to create a REST web service using JAX-RS. In that, I have PUT method or POST method which consumes the json as mediatype in the REST web service. Can I know how to call these methods from the client side. How do we pass that json as input from client side to those PUT and POST method and how would we consume the json format in the PUT or POST method from server side. If we want to consume xml, then we are using JAXBElement. For consuming json, how to do that ? This may help get you going: http://blog.sertik.net/labels/jersey.html From my (extremely rusty) recollection, you sort of

Unable to test HTTP PUT-based file upload via Squid Proxy

会有一股神秘感。 提交于 2019-12-05 18:39:42
I can upload a file to my Apache web server using Curl just fine: echo "[$(date)] file contents." | curl -T - http://WEB-SERVER/upload/sample.put However, if I put a Squid proxy server in between, then I am not able to: echo "[$(date)] file contents." | curl -x http://SQUID-PROXY:3128 -T - http://WEB-SERVER/upload/sample.put Curl reports the following error: Note: This error response was in HTML format, but I've removed the tags for ease of reading. ERROR: The requested URL could not be retrieved ERROR The requested URL could not be retrieved While trying to retrieve the URL: http://WEB-SERVER

python: HTTP PUT with unencoded binary data

此生再无相见时 提交于 2019-12-05 17:13:59
问题 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