LoginSignup
0
1

More than 3 years have passed since last update.

python2でRedmien

Posted at
redmine.py
# coding: utf-8

import csv
import urllib2

csv_filename = r'fullpath'
with open(csv_filename) as csvfile:
    reader = csv.DictReader(csvfile)
    for row in reader:
        print row['project'], row['title'], row['subject']

api_key = 'api-key'
url = 'http://ip/redmine/issues.xml'
xml = """<?xml version="1.0"?>
<issue>
<project_id>""" + str(row['project']) + """</project_id>
<subject>""" + str(row['title']) + """</subject>
<description>""" + str(row['subject']) + """</description>
</issue>"""

print xml

request = urllib2.Request(url, data=xml)
request.add_header('Content-Type', 'text/xml')
request.add_header('X-Redmine-API-Key', api_key)
request.get_method = lambda: 'POST'

# 登録実行
response = urllib2.urlopen(request)
ret = response.read()
print 'Response:', ret
0
1
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1