How to send an image to an api in dart/flutter?

The simplest method would be to post a multipart request like in this post and then post it to the server. Make sure to import these in the beginning of the file: import ‘package:path/path.dart’; import ‘package:async/async.dart’; import ‘dart:io’; import ‘package:http/http.dart’ as http; import ‘dart:convert’; Add this class somewhere in your code: upload(File imageFile) async { … Read more

How can I pass parameters from the command line to $_POST in a PHP script?

Just insert the following lines at the beginning of your script: /* If started from the command line, wrap parameters to $_POST and $_GET */ if (!isset($_SERVER[“HTTP_HOST”])) { parse_str($argv[1], $_GET); parse_str($argv[1], $_POST); } This small piece of code does the trick (you may decide if you want to use $_GET or $_POST or, like I … Read more

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