2

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.

enter image description here

2

2 Answers 2

2

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);
}
Sign up to request clarification or add additional context in comments.

Comments

0

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);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.