import 'package:http/http.dart' as http;
void main() {
// This will be sent as form data in the post requst
var map = new Map<String, dynamic>();
map['username'] = 'username';
map['password'] = 'password';
final response = await http.post(
Uri.parse('http/url/of/your/api'),
body: map,
);
print(response.body);
}
import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'package:http/http.dart' as http;
Future<http.Response> postRequest () async {
var url ='https://pae.ipportalegre.pt/testes2/wsjson/api/app/ws-authenticate';
Map data = {
'apikey': '12345678901234567890'
}
//encode Map to JSON
var body = json.encode(data);
var response = await http.post(url,
headers: {"Content-Type": "application/json"},
body: body
);
print("${response.statusCode}");
print("${response.body}");
return response;
}