agileware-jp / redmine_issue_templates

Redmine Issue Template. Pull requests, reporting issues, stars and sponsoring are always welcome!
https://www.redmine.org/plugins/redmine_issue_templates
GNU General Public License v2.0
65 stars 28 forks source link

Question: Is there a JSON code example to create a new ISSUE out of a TEMPLATE copy and fill it with parameters #54

Open WolfgangVetter opened 1 year ago

WolfgangVetter commented 1 year ago

Summary

Question: Is there a JSON code example to create a new ISSUE out of a TEMPLATE copy and fill it with parameters

Description

  1. in Javascript we give in some parameters for the new Issue

  2. Javascript starts a Groovy script like: ix.ajax().requestAppGroovy("RedmineIssueFromTemplate.groovy", { dataType: "json", data: { // Parameters ...

    },
    success: function (data)
    {
    }

    } and sends the parameters to Groovy

  3. in Groovy we create a JSON-String to send it to Redmine Example is for a new Issue only: StringBuilder json = new StringBuilder() json.append("{") json.append("\"issue\": {") json.append("\"project_id\":729,"); // json.append("\"subject\":\"WV TEST Issue\","); json.append("\"subject\":\"") json.append(sThema) json.append("\",") json.append("\"description\":\"") json.append(sBeschreibung) json.append("\",") json.append("\"tracker_id\":") json.append(iTrackerID + ",") json.append("\"priority_id\":") json.append(iPrioID + ",") json.append("\"assigned_to_id\":") json.append(iZugewiesenAnID + ",") json.append("\"start_date\":\"") json.append(sdtBeginn) json.append("\",") json.append("\"due_date\":\"") json.append(sdtAbgabe) json.append("\",") json.append("\"done_ratio\":") json.append(iProzent + "") // ------- Ende json.append("}}")

  4. set the URL def sURL = "http://tickets. ..../redmine/issues.json?key=abcdefghijklmnopqrstuvwyxz11223344556677"

  5. and send the POST to Redmine // Create the POST object and add the parameters try { HttpPost httpPost = new HttpPost(sURL); // send a JSON data httpPost.setEntity(new StringEntity(json.toString()));

    // Header ?
    httpPost.setHeader("Accept", "application/json");
    httpPost.setHeader("Content-type", "application/json; charset=UTF-8");
    
    try (CloseableHttpClient httpClient = HttpClients.createDefault();
        CloseableHttpResponse response = httpClient.execute(httpPost)) 
    {
    
        result = EntityUtils.toString(response.getEntity());
        // our Response
        sResponse = result
    }

    } ...

  6. now we need an example to create a new issue out of a given template f.e.: #10Template1 or #11Template2 ..., fill the new issue out with given parameters and give back the new issue number #xxxxx you write: "Support simple REST API with json format. ...."

Environment

grafik

Redmine version: 4.0.5.stable Installed plugins: redmine_issue_templates 0.3.7, but update ASAP to 1.1.0 OS Platform ist Windows 10 Database is MSSQL Intrexx is our development environment for Javascript Groovy ...

Expected Results

new issue number #xxxxx

Actual Results


Workaround


github-actions[bot] commented 1 year ago

Thank you for contributing to Redmine Issue Templates plugin!' first issue

WolfgangVetter commented 1 year ago

Is there any DOCUMENTATION to use an existing template as a new issue ?