Skip to content

Unable to send post form using http Library because of call of Uri.encodeQueryComponent with 2 parameters instead 1 ... #16131

Closed
@DartBot

Description

@DartBot

This issue was originally filed by [email protected]


What steps will reproduce the problem?
create a dart file like this :
import 'package:http/http.dart' as http;

main() {
  http.post('http://httpbin.org/post', body: {'key1': 'value1', 'key2': 'value2'}).then((response) {
    print("Response status: ${response.statusCode}");
    print("Response body: ${response.body}");
  });
}

What is the expected output? What do you see instead?
I expect to get a request with form data ... BUT i got
Unhandled exception:
No static method 'encodeQueryComponent' declared in class 'Uri'.

NoSuchMethodError: incorrect number of arguments passed to method named 'encodeQueryComponent'
Receiver: Type: class 'Uri'
Tried calling: encodeQueryComponent("key1", encoding: Instance of 'Utf8Codec')
Found: encodeQueryComponent(String)

­0 _rootHandleUncaughtError.<anonymous closure>.<anonymous closure> (dart:async/zone.dart:677)

­1 _asyncRunCallback (dart:async/schedule_microtask.dart:18)

­2 _asyncRunCallback (dart:async/schedule_microtask.dart:21)

­3 _createTimer.<anonymous closure> (dart:async-patch/timer_patch.dart:11)

­4 _Timer._createTimerHandler._handleTimeout (timer_impl.dart:151)

­5 _Timer._createTimerHandler._handleTimeout (timer_impl.dart:159)

­6 _Timer._createTimerHandler._handleTimeout (timer_impl.dart:159)

­7 _Timer._createTimerHandler.<anonymous closure> (timer_impl.dart:166)

­8 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:93)

What version of the product are you using? On what operating system?
http-0.9.2+1 library

Please provide any additional information below.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3A lower priority bug or feature requestarea-pkgUsed for miscellaneous pkg/ packages not associated with specific area- teams.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions