I need to make a GET request to an API from my Flutter app which request body as form-data.
I tested the API with JSON request body in Postman and it seems to be working fine.
I need to make a GET request to an API from my Flutter app which request body as form-data.
I tested the API with JSON request body in Postman and it seems to be working fine.
If you are using GET request method there can be two ways to to pass parameters as Query Paremeters or Path Paremeters
Your request dart code would be like
import 'package:http/http.dart' as http;
Future getPatientAppointments() async {
String appointmentUrl = "$url/api/PatientAppointments/GetMyPatientAppointmentAsDoctor";
String startDate = "01-05-2021";
String endDate = "01-05-2021";
var _response = await http.get(
Uri.parse("$appointmentUrl?startDate=$startDate&endDate=$endDate"),
);
print(_response.body);
}
Use this code, you can generate it by using code tap in postman
var request = http.MultipartRequest('GET', Uri.parse('http://192.168.131.172:8000/api/login'));
request.fields.addAll({
'email' : myControllerEmail.text,
'password' : myControllerPass.text
});
http.StreamedResponse response_streamed = await request.send();
var response = await http.Response.fromStream(response_streamed);