REST API always return error 500 Internal Server Error

Get help from other users here.

Moderators: Developer, Contributor

Post Reply
ZaRToP
Posts: 6
Joined: 21 Jan 2021, 09:46

REST API always return error 500 Internal Server Error

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

Re: REST API always return error 500 Internal Server Error

Post by atrol »

Your web server and / or PHP logs might contain some more information what's happening.
Please use Search before posting and read the Manual
ZaRToP
Posts: 6
Joined: 21 Jan 2021, 09:46

Re: REST API always return error 500 Internal Server Error

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

Re: REST API always return error 500 Internal Server Error

Post by atrol »

ZaRToP wrote:
21 Jan 2021, 10:03
Since yesterday afternoon ...
Did you change any configuration file (e.g. config_inc,php) yesterday?
Please use Search before posting and read the Manual
ZaRToP
Posts: 6
Joined: 21 Jan 2021, 09:46

Re: REST API always return error 500 Internal Server Error

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

Re: REST API always return error 500 Internal Server Error

Post 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.
Please use Search before posting and read the Manual
ZaRToP
Posts: 6
Joined: 21 Jan 2021, 09:46

Re: REST API always return error 500 Internal Server Error

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

Re: REST API always return error 500 Internal Server Error

Post 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
Please use Search before posting and read the Manual
ZaRToP
Posts: 6
Joined: 21 Jan 2021, 09:46

Re: REST API always return error 500 Internal Server Error

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

Re: REST API always return error 500 Internal Server Error

Post 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.
Please use Search before posting and read the Manual
ZaRToP
Posts: 6
Joined: 21 Jan 2021, 09:46

Re: REST API always return error 500 Internal Server Error

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

Re: REST API always return error 500 Internal Server Error

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