Is your feature request related to a problem? Please describe.
When I needed to add a query parameter to a HttpRequest, I used setParameter("key", "value"), which worked as expected when the method was GET, but when the method is POST and the content type is multipart/form-data, setParameter adds the parameter to the body. I also tried to add the query parameter manually via setPath("/endpoint?key=" + value), and since value has a space in it, I ended up using setPath("/endpoint?key=" + utils::urlEncodeComponent(value) (just like in the HttpRequest implementation) but for some reason that did not work
As I was writing this I found out that setPath() automatically encodes the path (maybe add something like "(see setPathEncode())" to the setPath doc comment) and it worked, but I'd prefer setQueryParameter as you could keep it consistent across requests, independent of the HTTP method
Describe the solution you'd like
I'd like to have either an overload for setParameter to explicitly specify query/body, or a pair of setQueryParameter/setBodyParameter functions where the former always adds to the query and the latter only works when the content type is multipart/form-data or application/x-www-form-urlencoded and will throw otherwise
Is your feature request related to a problem? Please describe.
When I needed to add a query parameter to a
HttpRequest, I usedsetParameter("key", "value"), which worked as expected when the method wasGET, but when the method isPOSTand the content type ismultipart/form-data,setParameteradds the parameter to the body. I also tried to add the query parameter manually viasetPath("/endpoint?key=" + value), and sincevaluehas a space in it, I ended up usingsetPath("/endpoint?key=" + utils::urlEncodeComponent(value)(just like in theHttpRequestimplementation) but for some reason that did not workAs I was writing this I found out that
setPath()automatically encodes the path (maybe add something like "(seesetPathEncode())" to thesetPathdoc comment) and it worked, but I'd prefersetQueryParameteras you could keep it consistent across requests, independent of the HTTP methodDescribe the solution you'd like
I'd like to have either an overload for
setParameterto explicitly specify query/body, or a pair ofsetQueryParameter/setBodyParameterfunctions where the former always adds to the query and the latter only works when the content type ismultipart/form-dataorapplication/x-www-form-urlencodedand will throw otherwise