Page 1 of 2

Error in REST API

Posted: 29 May 2018, 10:09
by mwas01
Hi,

I'm testing REST API in Mantis 2.14.0 and I receive followin error:

curl --request GET 'mantis/api/rest/issues?filter_id=monitored' --header 'Authorization: xyz'

<br />
<b>Fatal error</b>: Uncaught exception 'RuntimeException' with message 'Unexpected data in output buffer. Maybe you have characters before an opening &lt;?php tag?' in mantis/vendor/slim/slim/Slim/App.php:604
Stack trace:
#0 mantis/vendor/slim/slim/Slim/App.php(316): Slim\App-&gt;finalize(Object(Slim\Http\Response))
#1 mantis/api/rest/index.php(106): Slim\App-&gt;run()
#2 {main}
thrown in <b>mantis/vendor/slim/slim/Slim/App.php</b> on line <b>604</b><br />

Re: Error in REST API

Posted: 29 May 2018, 10:25
by atrol
I was not able to reproduce.

Did you check what the message is telling?
Maybe you have characters before an opening &lt;?php tag?'
E.g. there could be someting wrong with your config_inc.php

Re: Error in REST API

Posted: 29 May 2018, 10:51
by mwas01
Hi,

Yes, of course I checked it in the first place. There are no characters before it.
atrol wrote: 29 May 2018, 10:25 E.g. there could be someting wrong with your config_inc.php
Could you suggest what may be wrong with it? Only thing in config_inc.php that refers to REST API is:

# --- API Configuration ---
$g_webservice_rest_enabled = ON;

Re: Error in REST API

Posted: 29 May 2018, 11:14
by atrol
Check the encoding of config_inc.php.
Maybe it's UTF-8 with BOM.
It has to be UTF-8 without BOM.

Re: Error in REST API

Posted: 31 May 2018, 13:47
by mwas01
It's us-ascii so it's UTF-8 without BOM. I'll appreciate any other idea :)

Re: Error in REST API

Posted: 31 May 2018, 16:16
by atrol
Do you have installed a 3rd party plugin?
Do you use custom functions?
Did you customize strings in custom_strings_inc.php?
Did you change any original Mantis code?
Which PHP version do you use?

Re: Error in REST API

Posted: 04 Jun 2018, 14:28
by mwas01
atrol wrote: 31 May 2018, 16:16 Do you have installed a 3rd party plugin?
Do you use custom functions?
Did you customize strings in custom_strings_inc.php?
Did you change any original Mantis code?
Which PHP version do you use?
1. No, no 3rd party plugins are installed.
2. No.
3. Yes, there are several custom strings added.
4. No, it's standard Mantis release.
5. 5.6.32

Re: Error in REST API

Posted: 04 Jun 2018, 14:37
by atrol
Check that
- custom_strings_inc.php is UTF-8 without BOM
- there is no character before PHP open tag in custom_strings_inc.php
- there is no character after PHP close tag in custom_strings_inc.php (or ensure that there is no PHP close tag at the end of the file)

Re: Error in REST API

Posted: 07 Jun 2018, 13:51
by mwas01
I checked it, all files have UTF-8 without BOM encoding, there are no characters before php tag in custom_strings_inc, I removed close tag. I'm still getting same result.

Re: Error in REST API

Posted: 07 Jun 2018, 14:10
by atrol
What do you get if you login to your Mantis in browser and open <YourMantisURL>/api/rest/issues?filter_id=monitored

Re: Error in REST API

Posted: 08 Jun 2018, 08:11
by mwas01
I get exactly the same error message.

Re: Error in REST API

Posted: 09 Jun 2018, 09:17
by atrol
To be sure, other pages like <YourMantisURL>/my_view_page.php don't show any error?

Do you use a proxy to access your Mantis server?

Do you have configured some special rewrite rules on your web server?

Re: Error in REST API

Posted: 18 Jun 2019, 14:12
by Dealer_WeARE
I have the same problem. Api not work. I got the answer, for example:
jquery-2.2.4.min.js:4 GET https://.../bugreports/api/rest/index.php/plugins/Snippets/help 500
Snippets/snippets.js:147 Error occurred while retrieving Snippets pattern help
or like this:
https://.../bugreports/api/rest/index.php/lang Failed to load resource: the server responded with a status of 500 ()
I have this error with Chrome or FF browsers. But when I try IE or EDGE all works just fine. I have tried both MantisBT 2.21.0 and MantisBT 2.21.1.
At api/rest folder inside error_log i found some errors:
[18-Jun-2019 17:09:23 Europe/Kiev] PHP Fatal error: Uncaught exception 'RuntimeException' with message 'Unexpected data in output buffer. Maybe you have characters before an opening <?php tag?' in /.../.../bugreports/vendor/slim/slim/Slim/App.php:625
Stack trace:
#0 /.../.../bugreports/vendor/slim/slim/Slim/App.php(333): Slim\App->finalize(Object(Slim\Http\Response))
#1 /.../.../bugreports/api/rest/index.php(106): Slim\App->run()
#2 {main}
thrown in /.../.../bugreports/vendor/slim/slim/Slim/App.php on line 625

Re: Error in REST API

Posted: 19 Jun 2019, 08:08
by Dealer_WeARE
Well, I found more relative information. When I select at user settings English language all works fine in all browsers. When I change language to Russian - error occurs at all browsers (including EDGE). So this error not browser related but language. Any suggestions?

Re: Error in REST API

Posted: 19 Jun 2019, 11:11
by atrol
Did you add your own russian translation to the Snippets plugin?