-
Notifications
You must be signed in to change notification settings - Fork 362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
http post a map object using application/json content-type #16
Comments
<img src="https://avatars.githubusercontent.com/u/1343914?v=3" align="left" width="48" height="48"hspace="10"> Comment by sgjesse |
<img src="https://avatars.githubusercontent.com/u/188?v=3" align="left" width="48" height="48"hspace="10"> Comment by nex3 The auto-encoding of Maps for [body] is just utility functionality; it makes it easier to do the common case (sending form parameters) without cutting off other possibilities. You can always post arbitrary data by passing [body] a string or a List<int>. For example: http.post(url, Added NotPlanned label. |
Is there anyway to POST json with a property that has an array value? I've been trying to send a json object to a server which works unless I add a property with the value of array (a dart List) or a property with an int property. |
@efroim102, as a general rule please open a new issue instead of reviving long dead threads. To answer your question though, http.post(..) in itself does not handle JSON. |
@cskau-g Thanks, I was able to resolve this issue using a |
* Migrate to GitHub Actions * Delete .travis.yml * Update test-package.yml
Originally opened as dart-lang/sdk#17636
This issue was originally filed by [email protected]
I am encountering a problem trying to use the "package:http/http.dart' pub package to post some JSON data to a web service. I have formatted the data correctly (which I confirmed by posting using the Advanced REST Client extension for Chrome) and the only difference is the Content-Type is forced to the wrong type (the web service only accepts "application/json"):
If body is a Map, it's encoded as form fields using encoding. The content-type of the request will be set to "application/x-www-form-urlencoded"; this cannot be overridden.
The documentation suggests:
For more fine-grained control over the request, use Request or StreamedRequest instead.
Why is the post content type limited to only form-urlencoded? Can the pub package be fixed to set the content type dynamically?
The text was updated successfully, but these errors were encountered: