You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The above code always does the encoding of query parameters by using + instead of spaces. The issue is, some servers do not understand the +, instead they use %20.
Tried to manually encode the query paramater value but then it ends up to duplicated encoding.
How to prevent encoding or provive a Query Parameter encoder to support this case ?
// Current (Term=Hello World)
baseUrl/search?term=HELLO+WORLD
Expected (Term=Hello World)
// baseUrl/search?term=HELLO%20WORLD
Reacted by gthvmt, NeoKree, ahmadhp, cannoloops, Luca Venir, Artur Saidov, sridharmanikandan and Catalin Morosan
Hi everyone. According to Uri.encodeQueryComponent that is used in Transformer.urlEncodeMap, it's the right choice of the API. But I also want to test if I can provide another solution to change the code base:
Activity
xeinebiu commentedon Mar 16, 2022
Currently using the below workaround.
https://github.com/flutterchina/dio/blob/develop/dio/lib/src/transformer.dart#L45
Can be fixed by using
Uri.encodeComponent(value)instead.minhdangoz commentedon Sep 16, 2022
Thanks, it works with me
mb180594b commentedon Nov 24, 2022
I suggest you this change to avoid errors on the qp's types sent:
AlexV525 commentedon Dec 15, 2022
Hi everyone. According to
Uri.encodeQueryComponentthat is used inTransformer.urlEncodeMap, it's the right choice of the API. But I also want to test if I can provide another solution to change the code base:Try to replace:
https://github.com/flutterchina/dio/blob/9040bde4a07ffe4e201e4ec014242a16eb69d926/dio/lib/src/options.dart#L545-L550
To this:
This will drop the usage of the
ListFormat, but please let me know if it works.lucavenir commentedon Jan 18, 2024
This is completed because... there's a way to avoid encoding query parameters without the above workaround?
The above workaround doesn't work for me. The parameters still gets encoded. Aka I want to send a query param like so:
But even if I explicitly overwrite the above without encoding I still get
Which is pretty annoying. I have no other interceptors implemented / connected.
intraector commentedon Feb 10, 2025
Well, as it turns out, the only thing I had to do is just trim() the query. Works just fine.