Page 1 of 1

Rest API

Posted: 13 Jun 2017, 16:43
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.

Re: Rest API

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

Re: Rest API

Posted: 16 Oct 2017, 17:02
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?

Re: Rest API

Posted: 16 Oct 2017, 18:47
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?

Re: Rest API

Posted: 16 Oct 2017, 20:25
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!!!!!!!!!!!!!

Re: Rest API

Posted: 17 Oct 2017, 10:55
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 :(

Re: Rest API

Posted: 15 Feb 2018, 21:11
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>

Re: Rest API

Posted: 16 Feb 2018, 07:56
by atrol
Enabling URL rewriting in your web server might fix the issue.

Re: Rest API

Posted: 19 Feb 2018, 16:48
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.

Re: Rest API

Posted: 19 Feb 2018, 18:42
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.

Re: Rest API

Posted: 28 Jun 2018, 17:56
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?

Re: Rest API

Posted: 03 Aug 2018, 19:20
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>