Page 1 of 1

REST API always return error 500 Internal Server Error

Posted: 21 Jan 2021, 10:03
by ZaRToP
Hi,

Since yesterday afternoon, I have the REST API which always gives me a 500 error with the reason: "Internal Server Error" to each of my requests.

When I started using it it worked perfectly, then the next day when I wanted to create a user I had the 500 error but the user was still create, and now no queries are working anymore,

Could you help me please ?

Re: REST API always return error 500 Internal Server Error

Posted: 21 Jan 2021, 11:08
by atrol
Your web server and / or PHP logs might contain some more information what's happening.

Re: REST API always return error 500 Internal Server Error

Posted: 21 Jan 2021, 11:21
by ZaRToP
oh you're right, I got this error in the PHP logs :
PHP Fatal error: Uncaught RuntimeException: Unexpected data in output buffer. Maybe you have characters before an opening <?php tag? in /opt/bitnami/apps/mantis/htdocs/vendor/slim/slim/Slim/App.php:621\nStack trace:\n#0 /opt/bitnami/apps/mantis/htdocs/vendor/slim/slim/Slim/App.php(317): Slim\\App>finalize(Object(Slim\\Http\\Response))\n#1/opt/bitnami/apps/mantis/htdocs/api/rest/index.php(107): Slim\\App->run()\n#2 {main}\n thrown in /opt/bitnami/apps/mantis/htdocs/vendor/slim/slim/Slim/App.php on line 621

Re: REST API always return error 500 Internal Server Error

Posted: 21 Jan 2021, 11:42
by atrol
ZaRToP wrote: 21 Jan 2021, 10:03 Since yesterday afternoon ...
Did you change any configuration file (e.g. config_inc,php) yesterday?

Re: REST API always return error 500 Internal Server Error

Posted: 21 Jan 2021, 11:58
by ZaRToP
yes, i tried to comment some parameters and run without those parameters but the result was the same

Image

edit because the image does not load : https://prnt.sc/xd7w67

Re: REST API always return error 500 Internal Server Error

Posted: 21 Jan 2021, 12:04
by atrol
Your editor might have changed the encoding of the file when storing it.
It might now be UTF-8 with BOM, but it should be UTF-8 without BOM.

Re: REST API always return error 500 Internal Server Error

Posted: 21 Jan 2021, 13:53
by ZaRToP
when I do the "file config_inc.php" command, there is written that the file is in "ASCII text" : https://prnt.sc/xdgk8q

I tried to open the file with vim, and to make the command: ":set nobomb" but that didn't change anything

Re: REST API always return error 500 Internal Server Error

Posted: 21 Jan 2021, 14:28
by atrol
This is what I get

Code: Select all

file config_inc.php
config_inc.php: PHP script, ASCII text
Double check that there is not any character in this file (and maybe other files you changed) before

Code: Select all

<?php
e.g. run

Code: Select all

 od -c config_inc.php

Re: REST API always return error 500 Internal Server Error

Posted: 21 Jan 2021, 15:00
by ZaRToP
I found in one of the files I modified, I had a space before the <?php, I hadn't thought of looking in the other files.

Really thanks for your help

Re: REST API always return error 500 Internal Server Error

Posted: 21 Jan 2021, 16:17
by atrol
Glad to hear you fixed your problem.
ZaRToP wrote: 21 Jan 2021, 15:00 I found in one of the files I modified, I had a space before the <?php, I hadn't thought of looking in the other files.
Which file was it?

We check config_inc.php during runtime, so I would have expected you get also an issue in UI, but not just REST API.

Re: REST API always return error 500 Internal Server Error

Posted: 22 Jan 2021, 08:23
by ZaRToP
it was "layout_api.php", when I changed the footer, but yes weirdly, I had no problem in the UI, only with API

Re: REST API always return error 500 Internal Server Error

Posted: 31 Jan 2021, 11:32
by atrol
ZaRToP wrote: 22 Jan 2021, 08:23 it was "layout_api.php"
It's not recommended to change any of the original files. Your problem is a good example for this rule.
Be also aware that you have to reapply those changes whenever you install a new Mantis version.
All configuration should be done by using the configuration options or by writing a plugin.