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 ?