Add support for sending query string parameters AND a request body. #237

wants to merge 4 commits into


None yet
3 participants

Our API requires a query string parameter with each call. When this parameter is specified for PUT or POST requests RestSharp ignores the request body added with AddBody(). This is resolved by adding an AlwaysUseQueryString property to the RestRequest and Http classes.


johnsheehan commented Apr 3, 2012

This is sort of an edge case and can be handled by moving the querystring parameters into the method URL and setting their values with URL segments:

request = new RestRequest("foo?bar={bar}&fizz={fizz}");
request.AddUrlSegment("bar", 123);

I don't believe this use case justifies a change in RestRequest. Happy to discuss it more on the Google Group

@johnsheehan johnsheehan closed this Apr 3, 2012

Looks like I really over thought that one! I remember reading that the URL segment parameters used simple string replacement, just didn't think about applying it to the query string. Thanks for the reminder to keep it simple, John. :)

This is actually a pain point in RestSharp.
Sending query string parameters when POSTing is important.
Using AddUrlSegment will not always help, as sometimes (like in my case) query string parameters are sent by the user, I don't know them in advance.
Is there any reason why no to add support for this?
Probably request.AddQueryStringParameter or something similar?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment