0

I am trying to post a payload to a rest endpoint using the python requests library and having an issue with the formatting of the endpoint. The below code works:

endpoint="https://api.something/path/to/my/endpoint"
headers= {"Authorization": "Bearer <token>"}

req = requests.post(endpoint, headers=headers, data).json()

However I were to change the endpoint to something like this

my_var="my"
endpoint="https://api.something/path/to/{}/endpoint".format(my_var)

My post request no longer works giving me a not found . In both cases the endpoint resolves to the exact same URL but yet using format doesnt seem to work.

What am I missing ?

Mooncrater
  • 4,146
  • 4
  • 33
  • 62
letsc
  • 2,515
  • 5
  • 35
  • 54
  • 1
    Hi, perhaps enable tracing to verify the full request https://stackoverflow.com/questions/10588644/how-can-i-see-the-entire-http-request-thats-being-sent-by-my-python-application – IronMan Nov 04 '20 at 21:21
  • Hello, can you give details regarding: 1. The exact error 2. The exact url of the request? Normally, this works fine for me: `"https://api.something/path/to/"+my_var+"/endpoint"` – Mooncrater Nov 05 '20 at 06:42

0 Answers0