Post issues into mantis from java program

General discussion of Mantis.

Moderators: Contributor, Developer

Post Reply
shanthini
Posts: 19
Joined: Apr 10, 2010 7:01 am

Post issues into mantis from java program

Post by shanthini » Jun 29, 2018 2:54 am

Hi

We would like to post issues into mantis from java program. Please suggest whether REST api has support for java.

Thanks

atrol
Site Admin
Posts: 7257
Joined: Mar 26, 2008 4:37 pm
Location: Germany

Re: Post issues into mantis from java program

Post by atrol » Jun 29, 2018 6:04 am

REST is not language dependent in general as it's based on HTTP.
Please use Search before posting and read the Manual

shanthini
Posts: 19
Joined: Apr 10, 2010 7:01 am

Re: Post issues into mantis from java program

Post by shanthini » Jul 02, 2018 1:32 am

Hi ,

I am new MantisConnect webservice.
We would like to create an issues in mantis from java program using MantisConnect. Kindly share the if any samples available.

atrol
Site Admin
Posts: 7257
Joined: Mar 26, 2008 4:37 pm
Location: Germany

Re: Post issues into mantis from java program

Post by atrol » Jul 02, 2018 2:26 am

MantisConnect is not a Java but a C# (.NET) client for Mantis Bug Tracker.

Look at the Mylyn Connector for MantisBT ( Eclipse Plugin ) for a Java example https://github.com/Mylyn-Mantis/mylyn-mantis
Please use Search before posting and read the Manual

shanthini
Posts: 19
Joined: Apr 10, 2010 7:01 am

Re: Post issues into mantis from java program

Post by shanthini » Jul 02, 2018 6:30 am

Hi,
I need to attach image file(.png) along with my created issues using Mantis Rest API.



Please find my sample snippet i have working on using MantisRest API

URL url = new URL(" ")
HttpURLConnection conn= (HttpURLConnection) url.openConnection();
conn.setDoOutput(true);
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-Type", "application/json");
conn.setRequestProperty("Authorization", " ");// i have passed my authorization here
String input = "{\"summary\": \"This is a test issue from mantis\", \"description\": \"This is a test description from mantis\", \"category\": { \"id\": \"6\" }, \"project\": { \"id\": 215 } }";


could someone give pointers to add attachment with the issues i have created in Mantis Bug Tracker.

shanthini
Posts: 19
Joined: Apr 10, 2010 7:01 am

Re: Post issues into mantis through RestAPI

Post by shanthini » Jul 09, 2018 1:50 am

I am trying to post an issue with attachment through Rest API.
The issue gets created but the file attachments are not posted.
Please let me know how to solve this.

Below is my request details:
{
"method": "POST",
"transformRequest": [
null
],
"transformResponse": [
null
],
"url": "http://db3:81/bugtracker/api/rest/issues",
"headers": {
"Authorization": "aWjAGERB07B9kFgkw8mTm-YIMeDdweJ5",
"Content-Type": "application/json",
"Accept": "application/json, text/plain, */*"
},
"data": "{\n \"summary\": \"Sample REST issue-test\",\n \"description\": \"Description for sample REST issue.\",\n \"project\": { \"id\": 215 },\n \"category\": {\"id\": 6},\n \"files\":[\n{\n \"name\":\"test.txt\",\n\"content\":\"dGhpcyBpcyBhIHRlc3QgZmlsZQ0KdGhpcyBpcyB0byB0ZXN0IGF0dGFjaG1lbnRzDQohIyQhQCQhQCQhQCMlI0AhJSNAISUhIyUNCkVuZCBvZiBGaWxl\" \n}\n]\n}",
"timeout": {}
}

atrol
Site Admin
Posts: 7257
Joined: Mar 26, 2008 4:37 pm
Location: Germany

Re: Post issues into mantis from java program

Post by atrol » Jul 09, 2018 3:05 am

Maybe you are running an old Mantis version where this is not supported.
You have to use at least 2.13.0 https://www.mantisbt.org/bugs/view.php?id=22785
Please use Search before posting and read the Manual

Post Reply