0

how properly to make a get request with no params names? the api request must be like:

 url + '/smth/val1/val2'

usually do like so

payload = {p1:val1, p2:val2}
response = requests.get(url + '/smth', params=payload)

however, in that case I wrote the code:

requests.get(url + '/smth/{}/{}'.format(val1, val2))

is there any way to do it by using params key word?

NullUserException
  • 83,810
  • 28
  • 209
  • 234
Leo
  • 1,787
  • 5
  • 21
  • 43
  • `params` is designed to be used as parameters in a GET request. If the API has the parameters built into the URL itself then `params` won't work – NullUserException Aug 05 '16 at 17:07
  • As @NullUserException said, those parameters are outside the scope of the `requests` module. The way you're currently doing it (string formatting) is **just fine**. But if you want a more structured way of building URLs including those parameters, maybe have a look at the [`uritemplate`](https://pypi.python.org/pypi/uritemplate) package. – Lukas Graf Aug 07 '16 at 19:54

0 Answers0