Volley send JSONObject to server with POST method

You can use the following working sample code. I have tested. Hope this helps! try { jsonBody = new JSONObject(); jsonBody.put(“Title”, “VolleyApp Android Demo”); jsonBody.put(“Author”, “BNK”); jsonBody.put(“Date”, “2015/08/26”); requestBody = jsonBody.toString(); StringRequest stringRequest = new StringRequest(1, url, new Response.Listener<String>() { @Override public void onResponse(String response) { textView.setText(response); } }, new Response.ErrorListener() { @Override public void … Read more

File uploading using GET Method

GET requests may contain an entity body RFC 2616 does not prevent an entity body as part of a GET request. This is often misunderstood because PHP muddies the waters with its poorly-named $_GET superglobal. $_GET technically has nothing to do with the HTTP GET request method — it’s nothing more than a key-value list … Read more

REST API using POST instead of GET

I use POST body for anything non-trivial and line-of-business apps for these reasons: Security – If we use GET with query strings and https, the query strings can be saved in server logs and forwarded as referral links. Both of these are now visible by server/network admins and the next domain the user went to … Read more

How to send file contents as body entity using cURL

I believe you’re looking for the @filename syntax, e.g.: strip new lines curl –data “@/path/to/filename” http://… keep new lines curl –data-binary “@/path/to/filename” http://… curl will strip all newlines from the file. If you want to send the file with newlines intact, use –data-binary in place of –data

HTTP Request in Swift with POST method

In Swift 3 and later you can: let url = URL(string: “http://www.thisismylink.com/postName.php”)! var request = URLRequest(url: url) request.setValue(“application/x-www-form-urlencoded”, forHTTPHeaderField: “Content-Type”) request.httpMethod = “POST” let parameters: [String: Any] = [ “id”: 13, “name”: “Jack & Jill” ] request.httpBody = parameters.percentEncoded() let task = URLSession.shared.dataTask(with: request) { data, response, error in guard let data = data, let … Read more

How do you post to an iframe?

Depends what you mean by “post data”. You can use the HTML target=”” attribute on a <form /> tag, so it could be as simple as: <form action=”do_stuff.aspx” method=”post” target=”my_iframe”> <input type=”submit” value=”Do Stuff!”> </form> <!– when the form is submitted, the server response will appear in this iframe –> <iframe name=”my_iframe” src=”https://stackoverflow.com/questions/168455/not_submitted_yet.aspx”></iframe> If that’s … Read more