I have a str
payload looks like this
payload = "{\"fqdn\":\"examplazdazdazazdzadza.com\",\"duration\":5,\"owner\":{\"city\":\"Paris\",\"given\":\"Alice\",\"family\":\"Doe\",\"zip\":\"75001\",\"country\":\"FR\",\"streetaddr\":\"5 rue neuve\",\"phone\":\"+33.123456789\",\"type\":0,\"email\":\"alice@example.org\"}}"
This is the payload from the Gandi API
I want to make the payload a bit more dynamic and have some flexibility, so I tired dict
domain = 'example.com`
payload = {
'fqdn': domain,
'duration': 1,
'owner': {
"city": "Paris",
"given": "Alice",
"family": "Doe",
"zip": "75001",
"country": "FR",
"streetaddr": "5 rue neuve",
"phone": "+33.123456789",
"state": "FR-J",
"type": 0,
"email": "alice@example.org"
}
}
After this I need to revert back to the orginal datetype (str) and I do this like so
payload = '\n'.join('\%s\: "\%s\"' % (k, v) for k, v in payload.items())
However this returns
Bad Request
.
Any ideas how get this done properly?