Error in REST API

Get help from other users here.

Moderators: Developer, Contributor

mwas01
Posts: 7
Joined: May 29, 2018 5:02 am
Location: Sweden

Error in REST API

Post by mwas01 » May 29, 2018 5:09 am

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 />

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

Re: Error in REST API

Post by atrol » May 29, 2018 5:25 am

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
Please use Search before posting and read the Manual

mwas01
Posts: 7
Joined: May 29, 2018 5:02 am
Location: Sweden

Re: Error in REST API

Post by mwas01 » May 29, 2018 5:51 am

Hi,

Yes, of course I checked it in the first place. There are no characters before it.
atrol wrote:
May 29, 2018 5:25 am
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;
Last edited by mwas01 on May 30, 2018 3:00 am, edited 1 time in total.

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

Re: Error in REST API

Post by atrol » May 29, 2018 6:14 am

Check the encoding of config_inc.php.
Maybe it's UTF-8 with BOM.
It has to be UTF-8 without BOM.
Please use Search before posting and read the Manual

mwas01
Posts: 7
Joined: May 29, 2018 5:02 am
Location: Sweden

Re: Error in REST API

Post by mwas01 » May 31, 2018 8:47 am

It's us-ascii so it's UTF-8 without BOM. I'll appreciate any other idea :)

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

Re: Error in REST API

Post by atrol » May 31, 2018 11:16 am

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?
Please use Search before posting and read the Manual

mwas01
Posts: 7
Joined: May 29, 2018 5:02 am
Location: Sweden

Re: Error in REST API

Post by mwas01 » Jun 04, 2018 9:28 am

atrol wrote:
May 31, 2018 11:16 am
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

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

Re: Error in REST API

Post by atrol » Jun 04, 2018 9:37 am

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)
Please use Search before posting and read the Manual

mwas01
Posts: 7
Joined: May 29, 2018 5:02 am
Location: Sweden

Re: Error in REST API

Post by mwas01 » Jun 07, 2018 8:51 am

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.

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

Re: Error in REST API

Post by atrol » Jun 07, 2018 9:10 am

What do you get if you login to your Mantis in browser and open <YourMantisURL>/api/rest/issues?filter_id=monitored
Please use Search before posting and read the Manual

mwas01
Posts: 7
Joined: May 29, 2018 5:02 am
Location: Sweden

Re: Error in REST API

Post by mwas01 » Jun 08, 2018 3:11 am

I get exactly the same error message.

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

Re: Error in REST API

Post by atrol » Jun 09, 2018 4:17 am

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?
Please use Search before posting and read the Manual

Dealer_WeARE
Posts: 3
Joined: Jun 18, 2019 8:59 am

Re: Error in REST API

Post by Dealer_WeARE » Jun 18, 2019 9:12 am

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

Dealer_WeARE
Posts: 3
Joined: Jun 18, 2019 8:59 am

Re: Error in REST API

Post by Dealer_WeARE » Jun 19, 2019 3:08 am

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?

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

Re: Error in REST API

Post by atrol » Jun 19, 2019 6:11 am

Did you add your own russian translation to the Snippets plugin?
Please use Search before posting and read the Manual

Post Reply