0

I am having an issue with a http request I make using the python requests lib. When I make this query using the browsers, this is how the request looks like:

mysite/test?query=name%3A"My+Name+Is"*

Now, when I try to use the python lib, I use this dictionary as my params:

{'query' : 'name:My Name Is*'}

When I do this query using the browser, it works however, when I do this using the python lib, it does not work. Now my question is, should I be escaping the '*'? or are the spaces messing this up? the python lib should already be encoding this string so I would think I don’t need to do that prior to passing it. Any advice or comments are appreciated!

Here is a sample of the code making the request:

url = 'https://rink.hockeyapp.net/api/2/apps/app_id/app_versions/version_id/crash_reasons/search'
params={'per_page': 100, 'page': 1, 'query': 'reason:"Some String With Spaces*"'}
requests.get(url, params=params)
Rafthecalf
  • 461
  • 6
  • 20
  • Could you show us the code you've already tried? – skovorodkin Oct 03 '16 at 17:27
  • Possible duplicate of [URL encoding in python](http://stackoverflow.com/questions/8905864/url-encoding-in-python) – gre_gor Oct 03 '16 at 17:28
  • Updated the question with some sample code. – Rafthecalf Oct 03 '16 at 17:47
  • 1
    The python code you show in your question is not valid python code and won't run. – dsh Oct 03 '16 at 17:50
  • updated the code @dsh – Rafthecalf Oct 03 '16 at 20:48
  • That code works. Perhaps your parameters are not correct for that particular application's API? I ran it and it correctly URL-encoded to request the following: `/api/2/apps/app_id/app_versions/version_id/crash_reasons/search?per_page=100&page=1&query=reason%3A%22Some+String+With+Spaces%2A%22` The server replied with a `404 Not Found` response, which means that path was not found on that server. You can use wireshark to capture the traffic for debugging when you don't use SSL. – dsh Oct 04 '16 at 18:01

0 Answers0