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

Using Github Search Api does not work with complex search string #117

Closed
domjansen opened this issue Jun 11, 2014 · 3 comments
Closed

Using Github Search Api does not work with complex search string #117

domjansen opened this issue Jun 11, 2014 · 3 comments

Comments

@domjansen
Copy link

When i try to search against the Github api using the github example i get an 422 error.

In go code this looks like:

opt := &github.SearchOptions{Sort: "updated"}
client.Search.Code("addClass+in:file+language:js+repo:jquery/jquery", opt)

The error looks like:

error: GET https://api.github.com/search/code?q=addClass%2Bin%3Afile%2Blanguage%3Ajs%2Brepo%3Ajquery%2Fjquery&sort=updated: 422 Validation Failed [{Resource:Search Field:q Code:invalid}]

The Problem is that go encodes the query string and not only the params.
The Github Api isn't able to deal with such queries.

Go generated url:

$ curl https://api.github.com/search/code?q=addClass%2Bin%3Afile%2Blanguage%3Ajs%2Brepo%3Ajquery%2Fjquery&sort=updated

=> does not work

Same curl without encoding:

$ curl https://api.github.com/search/code?addClass+in:file+language:js+repo:jquery/jquery&sort=updated

=> works

We will prepare a pullrequest for this issue.

@willnorris
Copy link
Collaborator

rather than separating search operators by literal + characters, try spaces:

opt := &github.SearchOptions{Sort: "updated"}
client.Search.Code("addClass in:file language:js repo:jquery/jquery", opt)

I think that should work. If so, then the problem is really one of documenting that better.

@rgbkrk
Copy link
Contributor

rgbkrk commented Jun 11, 2014

I've been making very complex search queries with space separators. It's definitely a documentation thing.

@domjansen
Copy link
Author

Great, thank you :)

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

3 participants