Import attachment via REST API
Hi there,
i'm currently migrating serveral redmine instances into youtrack. So far i did it with the CSV2youtrack.py-Script. Which worked pretty well.
But how can i import attachments from redmine via the REST API?
i managed it to get the response "<login>ok</login>" but after this i'll get the message
So what is the "Field" that is required?
i used the following request via node.js:
i'm currently migrating serveral redmine instances into youtrack. So far i did it with the CSV2youtrack.py-Script. Which worked pretty well.
But how can i import attachments from redmine via the REST API?
i managed it to get the response "<login>ok</login>" but after this i'll get the message
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <importReport><item imported="false"><error fieldName="MIME attachment">Field is required</error></item></importReport>
So what is the "Field" that is required?
i used the following request via node.js:
var Client = require('node-rest-client').Client;
var client = new Client();
// set content-type header and data as json in args parameter
var args;
var cookie;
var boundary = "boundary=----WebKitFormBoundary6ECBGl5U5UnwBOqA";
var boundary2 = "----WebKitFormBoundary6ECBGl5U5UnwBOqA";
var loginRequest = client.post("http://yT-Server:8081/rest/user/login?login=root&password=******", args, function(data,response) {
console.log(data);
var cookies = response.headers["set-cookie"];
cookie = cookies[0] + cookies[1];
console.log(cookie);
args = {
data: "hallo",
headers: {
"Cookie": cookie,
"Content-Type": "multipart/form-data; "+boundary,
"Accept" : "*/*",
"Host" : "yT-Server:8081"
}
};
var content = ""+boundary2+"\n";
content += 'Content-Disposition: form-data; name="fileUpload"; filename="dummyfile.txt"\n';
content += 'Content-Type: text/plain\n';
content += 'Content-Transfer-Encoding: binary\n';
content += '\n';
content += ""+boundary2+"--\n";
console.log(content);
args.data = content;
args.headers["Content-Length"] = content.length;
client.post("http://yT-Server:8081/rest/import/test-1/attachment?test=true&authorLogin=root&created=1149678852000&file=dummyfile.txt", args, function(data,response) {
console.log(data);
});
});
Please sign in to leave a comment.