Rest API

General discussion of Mantis.

Moderators: Contributor, Developer

Post Reply
7h3ju57
Posts: 6
Joined: May 05, 2017 3:36 pm

Rest API

Post by 7h3ju57 » Jun 13, 2017 11:43 am

anyone successfully use the rest api?

I've tried via web browser and curl but always comes up with a 404.

I've tried enabling token authentication via $g_webservice_rest_enabled = ON;
Still no dice.
there is not much documentation on this feature either.

any help or suggestions would be greatly appreciated.

cdelaunay
Posts: 1
Joined: Sep 07, 2017 3:49 am

Re: Rest API

Post by cdelaunay » Sep 07, 2017 3:53 am

Same here.
We just installed version 2.6 of mantis.
An we would like to take advantage of the existing REST API functionality.
After looking for hours, we are not able to find any documentation on the web.
could someone give pointers to some sort of documentation around this REST API ?
Thanks in advance

Morettic
Posts: 3
Joined: Oct 16, 2017 11:26 am

Re: Rest API

Post by Morettic » Oct 16, 2017 12:02 pm

Yes i did. https://bugtracker.morettic.com.br/api/rest/issues/. Can list issues but found no documentation to write a client to it. Need to add ticket(issue) using rest API for my mobile APP. Any ideia?

Morettic
Posts: 3
Joined: Oct 16, 2017 11:26 am

Re: Rest API

Post by Morettic » Oct 16, 2017 1:47 pm

Im trying to write a simple PHP Client to Add Issues to the Mautic. Like the following PHP code....

Code: Select all

<?php

/*
 * @author LAMM <projetos@morettic.com.br>
 */

const BUGTRACKER_REST = "https://bugtracker.morettic.com.br/api/rest/issues/";

class BugTracker extends stdClass {

    public static function addIssueBugTracker($pUser, $pPass, $projectID, $category, $summary, $desc) {

        $fields = array(
            'username' => $pUser,
            'password' => $pPass,
            'category' => $category,
            'summary' => $summary,
            'description' => $desc,
            'project' => $projectID
        );

        var_dump($fields);

//url-ify the data for the POST
        foreach ($fields as $key => $value) {
            $fields_string .= $key . '=' . $value . '&';
        }
        rtrim($fields_string, '&');

//open connection
        $ch = curl_init();

//set the url, number of POST vars, POST data
        curl_setopt($ch, CURLOPT_URL, BUGTRACKER_REST);
        curl_setopt($ch, CURLOPT_POST, count($fields));
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
        curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);

//execute post
        $result = curl_exec($ch);

        var_dump($result);

//close connection
        curl_close($ch);
    }

}

Also changed issues_rest.php seems like no parameter is coming for username and password so....

Code: Select all

function rest_issue_add( \Slim\Http\Request $p_request, \Slim\Http\Response $p_response, array $p_args ) {
	$t_issue = $p_request->getParsedBody();

       // var_dump($t_issue);
        //echo "dadasdasd";die;
	$t_result = mc_issue_add( /* username */ 'mobXXXXXX', /* password */ 'm0bXXXXX', $t_issue );
Callback is empty. Also would like to know how to add extra fields. Any ideia?

Morettic
Posts: 3
Joined: Oct 16, 2017 11:26 am

Re: Rest API

Post by Morettic » Oct 16, 2017 3:25 pm

Code: Select all

<?php

/**
 * MantisBT / MantisHub PHP Client
 *
 * @author Victor Boctor (vboctor)
 * @license MIT License (MIT)
 *
 * Copyright (c) MantisHub - Victor Boctor
 * All rights reserved.
 */

namespace MantisHub;
//Missing until i fix it or dont work on Slim custom routes. below
use SoapClient;



I could connect at Soap API but after fix a BUG! needs uses SoapClient!!!!!!!!!!!!!

sarahah
Posts: 1
Joined: Sep 07, 2017 7:39 am

Re: Rest API

Post by sarahah » Oct 17, 2017 5:55 am

I want to call Salesforce via REST and I'm able to do a GET, but I can not make any API calls that require a POST. kindly help :(

milay
Posts: 2
Joined: Feb 14, 2018 2:50 pm

Re: Rest API

Post by milay » Feb 15, 2018 4:11 pm

As far as formatting the requests the link below is available & you may directly import into postman for testing.

https://documenter.getpostman.com/view/ ... pi/7Lt6zkP

I too receive a 404 error when I attempt to submit a GET. per the partner I am working with, not our system, the REST API is enabled. I am able to pull the swagger.json. At a loss at the moment. Open for suggestions.

GET http://<domain>/api/rest/issues?page_size=10&page=1

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html>
<head>
<title>404 Not Found</title>
</head>
<body>
<h1>Not Found</h1>
<p>The requested URL /api/rest/issues/ was not found on this server.</p>
</body>
</html>


<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html>
<head>
<title>404 Not Found</title>
</head>
<body>
<h1>Not Found</h1>
<p>The requested URL /api/rest/projects/ was not found on this server.</p>
</body>
</html>

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

Re: Rest API

Post by atrol » Feb 16, 2018 2:56 am

Enabling URL rewriting in your web server might fix the issue.
Please use Search before posting and read the Manual

milay
Posts: 2
Joined: Feb 14, 2018 2:50 pm

Re: Rest API

Post by milay » Feb 19, 2018 11:48 am

The server admin has enabled URL rewriting & is currently rewriting http to https. Any specifics on what should be rewritten?

As noted above this is not my server I simply trying to work with the owner of the server to gain access to the data. If it sounds like I am asking uneducated question then I am. Thanks for the assistance.

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

Re: Rest API

Post by atrol » Feb 19, 2018 1:42 pm

I am no specialist for this, especially if you user another web server than Apache
The rewriting is defined in file api/rest/.htaccess
You have to set "AllowOverride All" in Apache config and enable rewrite module, e.g. via a2enmod rewrite.
Please use Search before posting and read the Manual

esemelo
Posts: 1
Joined: Jun 28, 2018 12:42 pm

Re: Rest API

Post by esemelo » Jun 28, 2018 12:56 pm

@Milay, have you solved your problem?
I am working with mantisbt and xampp on localhost and i still get the 404 error. I've tried config mentioned by @atrol but it didn't worked.

Can anyone help me please?

bgamrat
Posts: 1
Joined: Aug 03, 2018 2:18 pm

Re: Rest API

Post by bgamrat » Aug 03, 2018 2:20 pm

These RewriteRules work for me

Code: Select all

<Directory /var/www/html/mantisbt-2.4.1/api/rest>
                RewriteEngine On
                RewriteRule .* index.php [L,QSA]
</Directory>
If you're going to use swagger ...

Code: Select all

        <Directory /var/www/html/bgamrat/mantisbt-2.4.1/api/rest>
                RewriteEngine On
                RewriteCond %{REQUEST_URI} !swagger
                RewriteRule .* index.php [L,QSA]
        </Directory>

Post Reply