Guest User

Untitled

a guest
Feb 22nd, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. import xlrd
  2. from collections import OrderedDict
  3. import simplejson as json
  4. import requests
  5.  
  6. wb = xlrd.open_workbook('Testmappe.xlsx')
  7.  
  8. sh = wb.sheet_by_index(0)
  9.  
  10. sb_list = []
  11.  
  12. for rownum in range(1, sh.nrows):
  13. sb = OrderedDict()
  14. row_values = sh.row_values(rownum)
  15. sb = row_values[0]
  16.  
  17. sb_list.append(sb)
  18. print(sb_list)
  19.  
  20.  
  21.  
  22. for item in range(len(sb_list)):
  23. data = {'article': {'title': sb_list[item], 'body': ???}}
  24.  
  25.  
  26. payload = json.dumps(data)
  27.  
  28. url = 'https://xxx.zendesk.com/api/v2/help_center/en-
  29. gb/sections/{id}/articles.json'
  30. user = 'user'
  31. password = 'password'
  32. headers = {'content-type': 'application/json'}
  33.  
  34. response = requests.post(url, data=payload, auth=(user, password),
  35. headers=headers)
  36.  
  37. if response.status_code != 201:
  38. print('Status:', response.status_code, 'Problem with the request.
  39. Exiting.')
  40. exit()
  41.  
  42. print('Successfully created category.')
Add Comment
Please, Sign In to add comment