Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import xlrd
- from collections import OrderedDict
- import simplejson as json
- import requests
- wb = xlrd.open_workbook('Testmappe.xlsx')
- sh = wb.sheet_by_index(0)
- sb_list = []
- for rownum in range(1, sh.nrows):
- sb = OrderedDict()
- row_values = sh.row_values(rownum)
- sb = row_values[0]
- sb_list.append(sb)
- print(sb_list)
- for item in range(len(sb_list)):
- data = {'article': {'title': sb_list[item], 'body': ???}}
- payload = json.dumps(data)
- url = 'https://xxx.zendesk.com/api/v2/help_center/en-
- gb/sections/{id}/articles.json'
- user = 'user'
- password = 'password'
- headers = {'content-type': 'application/json'}
- response = requests.post(url, data=payload, auth=(user, password),
- headers=headers)
- if response.status_code != 201:
- print('Status:', response.status_code, 'Problem with the request.
- Exiting.')
- exit()
- print('Successfully created category.')
Add Comment
Please, Sign In to add comment