Post issues into mantis from java program

General discussion of Mantis.

Moderators: Developer, Contributor

Post Reply
shanthini
Posts: 39
Joined: 10 Apr 2010, 12:01

Post issues into mantis from java program

Post by shanthini »

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: 8366
Joined: 26 Mar 2008, 21:37
Location: Germany

Re: Post issues into mantis from java program

Post by atrol »

REST is not language dependent in general as it's based on HTTP.
Please use Search before posting and read the Manual
shanthini
Posts: 39
Joined: 10 Apr 2010, 12:01

Re: Post issues into mantis from java program

Post by shanthini »

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: 8366
Joined: 26 Mar 2008, 21:37
Location: Germany

Re: Post issues into mantis from java program

Post by atrol »

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: 39
Joined: 10 Apr 2010, 12:01

Re: Post issues into mantis from java program

Post by shanthini »

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: 39
Joined: 10 Apr 2010, 12:01

Re: Post issues into mantis through RestAPI

Post by shanthini »

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: 8366
Joined: 26 Mar 2008, 21:37
Location: Germany

Re: Post issues into mantis from java program

Post by atrol »

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