Kirby 3: The form could not be saved, check your API connection

Hello!
Any ideas what might be causing this problem? After moving the Kirby installation to a dev server, I am unable to save changes in pages, getting the error pictured.

Kirby v3.0.1
PHP v7.3.1
phpinfo: http://dev.aparat-studio.com/info.php

05

Thanks!

Have you removed all files from the media folder? If not, try clearing it.
What about folder and file permissions?

Thanks for your reply.

I tried removing the /media folder and double-checked that the permissions are 755.

Tried reverting the install to vanilla kirby-starterkit, but the problem still persists.

I get the following error message in console, but I don‘t know how to check the API response.

Have you checked the network tab?

Thanks for the pointer. I did (see screenshot), but I honestly don’t know what the fix might be. I contacted the web hosting support to see if there might be a server settings/.htaccess entry that might be causing it.

The error seems to be thrown because the response is not proper JSON and therefore cannot be parsed. But I can’t see from that screenshot what is returned.

Have you also set ownership of the files correctly, not only permissions?

Hello Sonja, actually I just spoke to the hosting provider and it was a security setting on their part that rejected HTTP PATCH requests. Changing it resolved the issue.

Thank you for your help, closing the issue.

Hi Christian,

Do you knwo what specific security setting had to be changed? Could you ask the hosting provider maybe and find out and share this?

Probably mod_security like here: Kirby 3: Can't edit page content via panel in production

The Http Request Method PATCH is not often enabled. I managed to get it working with the Apache Module mod_allowmethods. This is an experimental module from apache 2.3 onwards, meant to replace usage of Limit. Once enabled, you can add something like the following in your conf file(s):

<Location “/”>
AllowMethods GET POST OPTIONS PATCH

Does anyone know how to get this working on NGINX?

I can’t delete images through the panel … am getting the message “The JSON response from the API could not be parsed. Please check your API connection.”

I’ve tried adding

location / {
	
  if ($request_method = 'OPTIONS') {
    add_header 'Access-Control-Allow-Origin' '*';
    add_header 'Access-Control-Allow-Methods' 'GET, POST, PATCH, PUT, DELETE, OPTIONS';
  }
	try_files $uri $uri/ /index.php?$query_string;
}

but to no avail.

I am getting this same error, but only when adding hooks. I am testing with code straight from docs:

'hooks' => [
    'page.create:before' => function ($event) {
        var_dump($event->name());   // 'page.create:before'
        var_dump($event->type());   // 'page'
        var_dump($event->action()); // 'create'
        var_dump($event->state());  // 'before'
        var_dump($event->page());   // $page
        var_dump($event->input());  // $input
    }
]

If I keep the hook, but remove var_dump then the save happens correctly still. Debug mode is enabled. Any ideas?

Oops, see now that the var_dump outputs into the JSON response, causing incorrect JSON and throwing the error. Maybe not the best way to show a hooks example on the docs!

That example is inside a Since 3.4.0 section. The code will work once Kirby 3.4.0 is released. :slight_smile:

You are right about that. I will change it.

Hi,
I had the same error message, for me the problem was coming from my blueprint file.yml, I was using french character (é).