Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 this issue Jan 24, 2023 · 2 comments

Comments

@WolfgangVetter
Copy link

WolfgangVetter commented Jan 24, 2023

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
Copy link

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

@WolfgangVetter
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant