New to programming in python. Looking to connect to an API, but don't fully understand calling arguments within a string, using curly braces. I realize this is a fairly basic concept, but I've been search and can't really find an explanation other than using .format()
values = """
{
"postUserLogin":{
"login":"{email_address}",
"password":"{password}",
"remember":1|0,
"verify_level":0|2
}
}"""
I tried
values.format(email_address ='test_email@gmail.com', password='mypass')
and I've tried just setting the variable normally.
Full API documentation to use from GoodData: https://help.gooddata.com/display/doc/API+Reference#/reference/authentication/log-in/log-in
from urllib2 import Request, urlopen
values = """
{
"postUserLogin":{
"login":"{email_address}",
"password":"{password}",
"remember":1|0,
"verify_level":0|2
}
}"""
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json'
}
request = Request('https://secure.gooddata.com/gdc/account/login', data=values, headers=headers)
response_body = urlopen(request).read()
print response_body