Advertisement
Guest User

Untitled

a guest
Sep 12th, 2017
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. import requests
  2. import json
  3.  
  4. # point to credentials
  5. import os
  6. import yaml
  7. myKeys = yaml.load(open(os.path.join(os.path.expanduser('~'), 'Documentskeyfile2.json')))
  8.  
  9. user = myKeys['PoliteMail'][1]['user']
  10. password = myKeys['PoliteMail'][1]['password']
  11. auth = requests.auth.HTTPBasicAuth(user, password)
  12.  
  13. base_url = 'https://comm.microsoft.com/ssv3/odata/'
  14. entity = 'Lists'
  15. url = base_url+entity
  16.  
  17. r = requests.get(url+'(56)', auth=auth)
  18. print(r.status_code) # '200'
  19.  
  20. payload = {
  21. "ID":"0",
  22. "Name":"Test List",
  23. "Description":"Does this work",
  24. "IsNewsletter":"0",
  25. "Shared":False,
  26. "CreationDate":"2014-11-19T23:00:00.000Z",
  27. "ActiveState":"1",
  28. "isAnonymous":False,
  29. "BusinessID":"0",
  30. "RegionID":"0"
  31. }
  32.  
  33. r = requests.post(url, data=json.dumps(payload),auth=auth)
  34.  
  35. r = requests.post(url, data=json.dumps(payload),auth=auth,
  36. headers = {"Content-Type": "application/json"})
  37.  
  38. {
  39. "odata.error":{
  40. "code":"","message":{
  41. "lang":"en-US","value":"The request is invalid."
  42. },"innererror":{
  43. "message":"contact : An error has occurred.rn","type":"","stacktrace":""
  44. }
  45. }
  46. }
  47.  
  48. 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