Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
MAAS API example: POST
import json
from requests import Request, Session
from requests_oauthlib import OAuth1
# <consumer_key>:<token_key>:<token_secret>
# xxxxxxxxxxxxxx:yyyyyyyyyyy:zzzzzzzzzzzzzz
auth1 = OAuth1(u'xxxxxxxxxxxxxx', u'',
u'yyyyyyyyyyy', u'zzzzzzzzzzzzzz')
headers = {'Accept': 'application/json'}
url = u''
body = json.dumps({'domain': '',
'name': 'demo',
'ip_addresses': '',
'address_ttl': '86400',
'fqdn': ''})
headers = {'Content-Type': 'application/json',
'Content-Length': str(len(body))}
s = Session()
req = Request('POST', url, data=body, headers=headers, auth=auth1)
prepped = req.prepare()
resp = s.send(prepped)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment