Redmine API with ColdFusion

A project I’m working on required a quick & easy way to add users to Redmine through the API, at first I thought it would be pretty simple, which it was, but it did give me a little headache.

From the Redmine API Docs they simply say to post a user hash table with the required information to /users.xml (or better yet .json!).  But a couple things came into play:
1: You must set the Content-Type to application/json
2: The user hash table can’t come in through url or form fields, it has to be serialized then posted to the body.
It took a long time searching google to find those two things out, since I can’t see it mentioned anywhere in the Redmine docs.

    var RedmineURL = '';
    var postData = {
        user = {
            login = 'NewApiUser',
            password = 'password',
            firstname = 'My',
            lastname = 'Name',
            mail = ''
    var httpService = new http();
    var result = httpService.send().getPrefix();
    writedump( deSerializejson(result.filecontent.ToString()) );

Quite Note: I just wrote the code free-hand here, but I’m pretty sure it works.

Leave a Comment

NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>