Rest API

General discussion of Mantis.

Moderators: Developer, Contributor

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

Rest API

Post by 7h3ju57 »

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: 07 Sep 2017, 08:49

Re: Rest API

Post by cdelaunay »

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: 4
Joined: 16 Oct 2017, 16:26

Re: Rest API

Post by Morettic »

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: 4
Joined: 16 Oct 2017, 16:26

Re: Rest API

Post by Morettic »

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: 4
Joined: 16 Oct 2017, 16:26

Re: Rest API

Post by Morettic »

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: 07 Sep 2017, 12:39
Contact:

Re: Rest API

Post by sarahah »

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: 14 Feb 2018, 19:50

Re: Rest API

Post by milay »

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

Re: Rest API

Post by atrol »

Enabling URL rewriting in your web server might fix the issue.
Please use Search before posting and read the Manual
milay
Posts: 2
Joined: 14 Feb 2018, 19:50

Re: Rest API

Post by milay »

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

Re: Rest API

Post by atrol »

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: 28 Jun 2018, 17:42

Re: Rest API

Post by esemelo »

@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: 03 Aug 2018, 19:18

Re: Rest API

Post by bgamrat »

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