Error in REST API

Get help from other users here.

Moderators: Developer, Contributor

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

Error in REST API

Post 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 />
atrol
Site Admin
Posts: 8366
Joined: 26 Mar 2008, 21:37
Location: Germany

Re: Error in REST API

Post 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
Please use Search before posting and read the Manual
mwas01
Posts: 7
Joined: 29 May 2018, 10:02
Location: Sweden

Re: Error in REST API

Post 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;
Last edited by mwas01 on 30 May 2018, 08:00, edited 1 time in total.
atrol
Site Admin
Posts: 8366
Joined: 26 Mar 2008, 21:37
Location: Germany

Re: Error in REST API

Post by atrol »

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: 29 May 2018, 10:02
Location: Sweden

Re: Error in REST API

Post by mwas01 »

It's us-ascii so it's UTF-8 without BOM. I'll appreciate any other idea :)
atrol
Site Admin
Posts: 8366
Joined: 26 Mar 2008, 21:37
Location: Germany

Re: Error in REST API

Post 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?
Please use Search before posting and read the Manual
mwas01
Posts: 7
Joined: 29 May 2018, 10:02
Location: Sweden

Re: Error in REST API

Post 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
atrol
Site Admin
Posts: 8366
Joined: 26 Mar 2008, 21:37
Location: Germany

Re: Error in REST API

Post 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)
Please use Search before posting and read the Manual
mwas01
Posts: 7
Joined: 29 May 2018, 10:02
Location: Sweden

Re: Error in REST API

Post 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.
atrol
Site Admin
Posts: 8366
Joined: 26 Mar 2008, 21:37
Location: Germany

Re: Error in REST API

Post by atrol »

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: 29 May 2018, 10:02
Location: Sweden

Re: Error in REST API

Post by mwas01 »

I get exactly the same error message.
atrol
Site Admin
Posts: 8366
Joined: 26 Mar 2008, 21:37
Location: Germany

Re: Error in REST API

Post 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?
Please use Search before posting and read the Manual
Dealer_WeARE
Posts: 3
Joined: 18 Jun 2019, 13:59

Re: Error in REST API

Post 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
Dealer_WeARE
Posts: 3
Joined: 18 Jun 2019, 13:59

Re: Error in REST API

Post 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?
atrol
Site Admin
Posts: 8366
Joined: 26 Mar 2008, 21:37
Location: Germany

Re: Error in REST API

Post by atrol »

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