How can I use JQuery to post JSON data?

You’re passing an object, not a JSON string. When you pass an object, jQuery uses $.param to serialize the object into name-value pairs. If you pass the data as a string, it won’t be serialized: $.ajax({ type: ‘POST’, url: ‘/form/’, data: ‘{“name”:”jonas”}’, // or JSON.stringify ({name: ‘jonas’}), success: function(data) { alert(‘data: ‘ + data); }, … Read more

ASP.net Core RC2 Web API POST – When to use Create, CreatedAtAction, vs. CreatedAtRoute?

There’s a few different questions here which should probably be split out, but I think this covers the bulk of your issues. Why create names for actions and routes? What’s the difference between action names and route names? First of all, actions and routes are very different. An Action lives on a controller. A route … Read more

HTTP POST payload not visible in Chrome debugger?

There was a regression bug in Chrome v61 and v62 across all platforms that caused this behaviour when the response is (amongst others) a 302. This is fixed in v63 stable which was released to all desktop platforms on 6th December 2017. Automatic updates are phased, but going to “Help”https://stackoverflow.com/”About Google Chrome” will force it … Read more

OkHttp Post Body as JSON

Just use JSONObject.toString(); method. And have a look at OkHttp’s tutorial: public static final MediaType JSON = MediaType.parse(“application/json; charset=utf-8”); OkHttpClient client = new OkHttpClient(); String post(String url, String json) throws IOException { RequestBody body = RequestBody.create(json, JSON); // new // RequestBody body = RequestBody.create(JSON, json); // old Request request = new Request.Builder() .url(url) .post(body) .build(); … Read more

Sending an HTTP POST request on iOS

The following code describes a simple example using POST method.(How one can pass data by POST method) Here, I describe how one can use of POST method. 1. Set post string with actual username and password. NSString *post = [NSString stringWithFormat:@”Username=%@&Password=%@”,@”username”,@”password”]; 2. Encode the post string using NSASCIIStringEncoding and also the post string you need … Read more

Send POST request with JSON data using Volley

JsonObjectRequest actually accepts JSONObject as body. From this blog article, final String url = “some/url”; final JSONObject jsonBody = new JSONObject(“{\”type\”:\”example\”}”); new JsonObjectRequest(url, jsonBody, new Response.Listener<JSONObject>() { … }); Here is the source code and JavaDoc (@param jsonRequest): /** * Creates a new request. * @param method the HTTP method to use * @param url … Read more

Uploading file using POST request in Node.js

Looks like you’re already using request module. in this case all you need to post multipart/form-data is to use its form feature: var req = request.post(url, function (err, resp, body) { if (err) { console.log(‘Error!’); } else { console.log(‘URL: ‘ + body); } }); var form = req.form(); form.append(‘file’, ‘<FILE_DATA>’, { filename: ‘myfile.txt’, contentType: ‘text/plain’ … Read more

Logging POST data from $request_body

This solution works like a charm: http { log_format postdata $request_body; server { location = /post.php { access_log /var/log/nginx/postdata.log postdata; fastcgi_pass php_cgi; } } } I think the trick is making nginx believe that you will call a CGI script. Edit 2022-03-15: there is some discussion on where log_format should be set. The documentation clearly … Read more