Reputation: 157
Complete Noob to curl, REST APIs and redmine stuck on something that might be quite simple but I cannot find an answer to it despite trawling the forums for a long time...
I have been trying to batch import multiple issues to Redmine without success.
I am now experimenting with the REST api using curl. I can post issues individually but cannot figure out how I can POST many issues at the same time? I assume that this is a common problem faced by people importing lots of stuff to redmine...
this is the curl command I am using:
curl -v -H "Content-Type: application/json" -X POST --data "@test2.json" \
-u user:password localhost/redmine/issues.json
and this is the test2.json file:
{
"issue": {
"project_id": 9,
"subject": "TEST5",
"notes": "foobar",
"priority_id": 2
},
"issue": {
"project_id": 9,
"subject": "TEST6",
"notes": "barfoo",
"priority_id": 3
}
}
Currently it only picks up the second issue... Can anybody suggest what I may be doing wrong or a better alternative?
Bitnami Redmine stack on Windows 7
Redmine version 2.3.0.stable
Ruby version 1.9.3 (i386-mingw32)
Rails version 3.2.13
Environment production
Database adapter Mysql2
Upvotes: 2
Views: 5909
Reputation: 2004
I posted a comment there, still need to document isntallation, for those who don't know composer. It's a CSV importer, if you know PHP you can add more input formats in the parser class family. https://github.com/juanmf/RedmineIssueImporter
Basically you define the csv field to Issue field mapping in the yml and run the script.
Upvotes: 0
Reputation: 157
I found the easiest solution for importing external data here:
http://www.redmine.org/boards/1/topics/37725?r=38232
This allows import direct from csv which works out perfectly for me!
Upvotes: 0
Reputation: 1789
Try using the python module called requests. It'll help you open URLs so you can POST and GET information from Redmine. This is what I used to push data to my local Redmine server.
For example, you can POST users to Redmine via this format:
username = 'admin'
password = 'admin'
url = 'http://localhost:3000/users.json'
payload = {
'user': {
'login': login,
'password': password,
'firstname': firstname,
'lastname': lastname,
'mail': mail
}
}
parameters_json = json.dumps(payload)
headers = {'Content-Type': 'application/json'}
r = requests.post(url, auth=(username, password), data=parameters_json, headers=headers)
So instead of users, POST to issues via: localhost:3000/issues.json
And follow Redmine's RESTful API guide, so that you're entering the right parameters.
Upvotes: 3