The JSON response from the API could not be parsed
Closed this issue ยท 9 comments
Hi guys, this is an help request for an error on static-site-generation request.
Expected Behavior
static
folder generation with the static files.
Current Behavior
I've this error in the panel The JSON response from the API could not be parsed. Please check your API connection.
, while in network tab I have a Status Code: 302 Found
Steps to Reproduce
Here my config options
'd4l' => [
'static_site_generator' => [
'endpoint' => 'generate-static-site',
'output_folder' => './static',
'preserve' => [],
'base_url' => '/',
'skip_media' => false,
'skip_templates' => []
]
],
Context
Kirby version 3.0
Additional plugins:
"diverently/laravel-mix-kirby": "^1.1",
"bnomei/kirby3-autoid": "^1.4",
"mzur/kirby-uniform": "^4.0",
"bnomei/kirby3-janitor": "^1.4",
"bvdputte/kirby-log": "^1.0",
"sylvainjule/previews": "^1.0",
"rasteiner/k3-pagesdisplay-section": "^0.0.5"
Many thanks!
Hi @Nic1911, thanks for reporting! Can you please try if it works now with the latest version of the plugin?
Hi @jonathan-reisdorf, I've just tried your last release.
Unfortunately the response is an error related to Kirby Uniform plugin: "The CSRF token was invalid".
After that I've disabled the plugin, but the error doesn't seem to be resolved...
The difference I can notice seems to be the api status 500.
Thanks for your support! ๐
Hi @Nic1911, I also ran into a similar error message while deploying locally. My terminal console gave me the error: PHP Fatal error: Maximum execution time of 30 seconds exceeded in /Users/.../my-project/vendor/claviska/simpleimage/src/claviska/SimpleImage.php on line 249
I set a time limit of 60seconds in my deployment, and it generated successfully. Hopefully it works for you, too.
Hi @bensanlau, could you give me a further example how to set a time limit, please? I'm not skilled enough on php ๐ฉ.
Thanks a lot!
@Nic1911 you can adapt this timeout with the max_execution_time
setting.
https://www.php.net/manual/en/info.configuration.php#ini.max-execution-time
Depending on your php installation the recommended way to change this value differs. If you have an extremely simple setup, you can simply adjust the value in your php.ini
, but if you used a package manager to install php, this might add complications when updating your php installation later.
PHP also allows you to have additional, separate ini files for further configuration. Depending on your installation there might be a conf.d
folder or, e.g. if you're using php-fpm, you can also adjust ini settings via your pool.d conf files.
As a quickfix, it might also work to dynamically set the timeout dynamically (runtime) with ini_set
.
Please let me know if you need further advice. For now I'll assume that the issue is solved.
I'm really sorry for the delay @jonathan-reisdorf.
I've tried adapting the max_execution_time setting on 60 as suggested, but it still doesn't works.
The error message is the same: "The JSON response from the API could not be parsed. Please check your API connection.".
Any other idea?
In the picture you can see the error in the console, hope it's can be useful.
Thank you
Thanks for the answer. To further debug into the issue, you'd need to have a look at the Response tab of the network request, please (in your screenshot that would be the "Risposta" tab on the right side). This one should give you more details about the issue that occurred. Then, depending on that, you'll either need to increase the max execution time to an even higher number or there's another error. By the way, when updating to the latest version of the static site generator plugin, rebuilding the static site should be much faster after the first time.
Hi @jonathan-reisdorf, after update to the latest version the operation is successful ๐ช
Many thanks for your patience and your support.