It seems your string is not formatted/escaped properly. How about doing something which is more readable, such as:
import requests
# some example values because your question doesn't give too many details
user, password ="user", "password"
url="http://google.com" # example url
headers={'pragma': 'no-cache'} # whatever your headers are
# now do the request, note we're not passing a single string here
requests.post(
url,
json={
"user": user,
"password": password
},
headers=headers
)
Additionally, I'd encourage you to work with something a bit easier than those unreadable strings! Put it into something that python (and us) can work with more easily. The first thing I'd do is get your string into a python object:
import json
payload = "{\r\"user\": \"{}\",\r\"password\": \"{}\",\r\"gdn\": 0\r}"
data=json.loads(payload)
data.update({'password': 'secret', 'user': 'me'})
# {u'password': 'secret', u'user': 'me', u'gdn': 0}
And finally, if you truly want to use the {}
as the format string (which I hope the rest of my answer shows you is much more difficult than you need to make it), you'll need to remove the leading and trailing braces in the formatted text:
"{" + "\r\"user\": \"{}\",\r\"password\": \"{}\",\r\"gdn\": 0\r".format("user", "secret") + "}"
# '{\r"user": "user",\r"password": "secret",\r"gdn": 0\r}