Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- import json
- # point to credentials
- import os
- import yaml
- myKeys = yaml.load(open(os.path.join(os.path.expanduser('~'), 'Documentskeyfile2.json')))
- user = myKeys['PoliteMail'][1]['user']
- password = myKeys['PoliteMail'][1]['password']
- auth = requests.auth.HTTPBasicAuth(user, password)
- base_url = 'https://comm.microsoft.com/ssv3/odata/'
- entity = 'Lists'
- url = base_url+entity
- r = requests.get(url+'(56)', auth=auth)
- print(r.status_code) # '200'
- payload = {
- "ID":"0",
- "Name":"Test List",
- "Description":"Does this work",
- "IsNewsletter":"0",
- "Shared":False,
- "CreationDate":"2014-11-19T23:00:00.000Z",
- "ActiveState":"1",
- "isAnonymous":False,
- "BusinessID":"0",
- "RegionID":"0"
- }
- r = requests.post(url, data=json.dumps(payload),auth=auth)
- r = requests.post(url, data=json.dumps(payload),auth=auth,
- headers = {"Content-Type": "application/json"})
- {
- "odata.error":{
- "code":"","message":{
- "lang":"en-US","value":"The request is invalid."
- },"innererror":{
- "message":"contact : An error has occurred.rn","type":"","stacktrace":""
- }
- }
- }
- payload = {"ID":"0","Name":"Test List","Description":"Does this work","IsNewsletter":"0","Shared":False, "CreationDate":"2014-11-19T23:00:00.000Z","ActiveState":"1","isAnonymous":False,"BusinessID":"0","RegionID":"0"}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement