Skip to content
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

AddQueryString generates invalid url #44

Open
ghost opened this issue Aug 25, 2014 · 4 comments
Open

AddQueryString generates invalid url #44

ghost opened this issue Aug 25, 2014 · 4 comments

Comments

@ghost
Copy link

ghost commented Aug 25, 2014

Incorrectly Generates url as:
"http://mydomain.com/v2/EndPointName/?&sample=12"
Should be:
"http://mydomain.com/v2/EndPointName/?sample=12"

var request = new RestRequest("EndPointName/"), System.Net.Http.HttpMethod.Post);
request.AddQueryString("sample", 12);

var client = new RestClient();
client.BaseUrl = "http://mydomain.com/v2/";
// .. add some headers

RestResponse response = await client.SendAsync(request);

@robertmclaws
Copy link
Collaborator

Sorry for the delay in getting back to you. We generated the URL this way because it is still syntactically valid, and it cut down on the code required to generate the string. Is there a situation where it is causing the code to error out?

@brunck
Copy link

brunck commented Oct 31, 2014

Yes I have this problem too. It is apparently not necessarily syntactically correct to have the & right after the ?. I am getting response code 400 Invalid Request Parameter, and the reason is exactly that: the &.

It would be helpful to have this fixed, even if there is a bit of effort to generate the proper string.

@robertmclaws
Copy link
Collaborator

RFC3986 does not specifically exclude this syntax, and IIS for example is able to handle it properly. What service are you trying to access that is experiencing the error?

@brunck
Copy link

brunck commented Nov 3, 2014

http://realtime.mbta.com/developer/api/v2/routes?&api_key=wX9NwuHnZU2ToO7GmGR9uw&format=json

You can use this directly as above, and you get the 400 error with "Invalid query parameter:" Remove the initial "&" and it works. This does use IIS, and may or may not be stopped at the server level, but as you can see it does not work. Others are clearly having this problem too as noted. I wouldn't be surprised if the reason other people are trying to investigate 400 errors, as noted in other issues here, are having the same problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants