put

Handling a POST request with libmicrohttpd

橙三吉。 提交于 2019-12-12 10:08:26
问题 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

How to create a GET, POST, and PUT request in Swift?

☆樱花仙子☆ 提交于 2019-12-12 08:15:23
问题 I can connect to a server synchronously with this code snippet in swift. let URL: NSURL = NSURL(string: "http://someserver.com)! let InfoJSON: NSData? = NSData(contentsOfURL: URL) let JsonInfo: NSString = NSString(data:InfoJSON!, encoding: NSUTF8StringEncoding)! let GameListAttributions: NSArray = NSJSONSerialization.JSONObjectWithData(InfoJSON!, options: .allZeros, error: nil)! as NSArray This is only good for receiving information all at once, but how would I use a GET, POST, and PUT with

Questions on proper REST api design specifically on the PUT action when updating a resource

♀尐吖头ヾ 提交于 2019-12-12 04:54:58
问题 I'm creating a REST interface (aren't we all), and I want to UPDATE a resource. So, I think to use a PUT. So, i read this. My take away is that i PUT to a URL like this /hc/api/v1/organizer/event/762d36c2-afc5-4c51-84eb-9b5b0ef2990c with a payload, then a permanent redirect to the URL that it can GET an updated version of the resource. In this case it happens to be the same URL, different action. So my questions are: Is my understanding of updating a resource correct in using a PUT, and is my

HTTP Error 415 Unsupported media type

天大地大妈咪最大 提交于 2019-12-12 04:18:40
问题 I am still on the same problem as: Upload binary data with HTTP PUT with jersey jaxrs-ri-2.01 But I am one step further. Now I am testing my data upload with this tool: I'm Only Resting The problem, and I don't know if it's a client or a server problem is that when I'm testing, I get HTTP 415 - Unsupported Media Type In the client: I have checked the PUT method In the body I have put one blank line (return) and in the second line i wrote test In the server, It was working until I added this

Can I change a date on shopify blog using api?

て烟熏妆下的殇ゞ 提交于 2019-12-12 03:43:12
问题 I must be brief, not much time left... I'm trying to backdate some blog posts that were written in the run-up to our store launch. I'm using curl from the command line and I can POST new blog articles, and I can PUT changes to existing blog articles, but I can't adjust the date of the existing articles yet. Can you help me? Thanks! Here's my curl request... curl -i -H "Content-Type: application/json" -H "Accept: application/json" -X PUT -d '{ "article": {"id": xxxxxx, "created_at": "2012-08

predictionio: why can I make post requests with curl but not python?

孤街浪徒 提交于 2019-12-12 01:54:28
问题 I am trying to import data into predictionio. I can send each event individually with curl fine: curl -i -X POST http://localhost:7070/events.json?accessKey=285285285 \ -H "Content-Type: application/json" \ -d '{ "event" : "buy", "entityType" : "user", "entityId" : "u1", "targetEntityType" : "item", "targetEntityId" : "i2", "eventTime" : "2014-11-10T12:34:56.123-08:00" }' HTTP/1.1 201 Created Server: spray-can/1.3.3 Date: Fri, 23 Dec 2016 00:02:32 GMT Content-Type: application/json; charset

rest api update resource with partial json

血红的双手。 提交于 2019-12-12 01:29:25
问题 Want to understand good practice to design REST API If a resource needs to be update partially, which is better? PUT or PATCH Please advice if my understanding is correct POST - to persist Customer with 2 address {"custId":"1", "name":"Rocky", "address":[{"id":"1","zip":"1234"}, {"id":"2","zip":"12345"}] } Now to update zip code for address id 1 PUT - full JSON is a requirement to be sent to REST API ? {"custId":"1", "name":"Rocky", "address":[{"id":"1","zip":"9876"}, {"id":"2","zip":"12345"}

Zend & method=“put”

自作多情 提交于 2019-12-12 00:55:58
问题 My app seems to be completely ignoring the PUT action. I have a controller with GET, POST, PUT and DELETE actions using REST. Both PUT and DELETE methods seem to be ignored. Perhaps it's an action and method syntax issue? Anyway here is some sample code: public function init() { // Set the method for the display form to PUT $this->setMethod('PUT'); $this->setAction('/article/?update'); } From Controller: public function putAction() { echo "putAction";exit(); } In my .htaccess I also allow

How to upload a file using the PUT method via Ajax in Spring MVC?

北城以北 提交于 2019-12-11 18:48:59
问题 I have the following js code to send an Ajax request to a URL which maps a method in Spring MVC. function update(id) { $.ajax({ datatype:"json", type: "put", url: "/wagafashion/ajax/TempAjax.htm", data: "id=" + id+"&t="+new Date().getTime(), success: function(response) { alert(response); }, error: function(e) { alert('Error: ' + e); } }); } and the following is the simple Spring form that has only a file browser and a button. <form:form id="mainForm" name="mainForm" method="post" action="Temp

How to parse request parameter (query and path param) and request body in same POJO in REST API

五迷三道 提交于 2019-12-11 16:37:30
问题 I have a rest API (PUT verb) which accepts both request body and path params: Ex: curl --data {a:1, b:2} -X PUT "https://example.com/users/{username}/address/{addressname}" I am trying to fetch both request body and path param in one POJO Response myAPI(@BeanParam Users user){ system.out.println(user.username); system.out.println(user.a); Users class public class Users{ @PathParam(username) private String userName; ...... private String a; ...... } But I am getting value of user.a as null.