API POST Error 510 (not extended) when trying to save page


When I try to save my first page (with selfmade blueprint) with custom image fields I get an error:
Exception: undefined / The JSON response from the API could not be parsed. Please check your API connection.

Console error:
app.js:1 POST http://.../api/pages/home 510 (Not Extended)

Blueprint (.yml file):

Thanks in advance for any help or hints for how I can get that fixed…

Hey, welcome to the Kirby forum :wave:!

Could you please provide some more information about your setup, server type, PHP version, operating system, local development setup etc.

And also please post the blueprint that causes this error.

I suppose you are using Kirby 3.5?

When I open the frontend url you posted above ( http://kirby.kafitheodor.ch), I’m greeted with an error message. It would be helpful if you also enable debugging in your config.

Thank you. I attached the blueprint as a screenshot. I am using Kirby 3.4.5…

Ps. Is that the blueprint for the home page that is causing the error? Can you edit and save other pages with other blueprints as expected?

Could you please enable debugging like I asked above so that we can see what the error message on the frontend is?

Are you using a Starterkit as basis? Or is this project created from scratch?

I am very sorry I am new to this, I have already noticed that /site/config/… doesn’t exist in my installation, so I can’t find the place where to enable debugging. It may be in another directory, haven’t found it yet.

Yes I can edit and save other pages with other blueprints, I assume it has to do with that blueprint or the images I upload…

Don’t worry, it’s not always easy to know the background of new people here. We’ll be getting there.

If you don’t have a config file, add one in /site/config/config.php, and if even the folder doesn’t exist, also create the folder.

Enabling debugging: https://getkirby.com/docs/reference/system/options/debug

I tried to open the home page in a Rest client, and get the error message that the home page does not exist. Have you deleted the home folder from your content?

The content/home folder is a required folder (same with the error folder) and may not be deleted unless you set the home option to a different folder in your config:

The error only occurs when I add images to one of the fields and then try to save the page.
Homepage is there again, I deleted it temporarily. The project is created from scratch.

Is there something wrong with my blueprint?

Edit: Despite the error, the page is saved somehow with the image and the page works, which is nice for now, but the error message bugs me still a little…

I don’t see anything wrong with it. Just as a remark for the future (no action needed now): Don’t post code as screenshots but copy/paste your code here. So if we need to test it, we can just copy it.

The error on the homepage has now disappeared as well.

Do you really still get this 510 error? Have you cleared the browser cache, the session (logged out and in again)?

Yes, and still the same error…

Still the same error when saving
When I try to add pages to the pages field named “navpages” as defined in my site.yml and then try to save it I get the same error again just with the difference that it doesn’t really save it to the site.txt file, it leaves the "Navpages: " empty…

site.yml looks like this:

title: Website
    label: Inhalt
    icon: page
        width: 2/3
            headline: Seiten
            type: pages
            label: Seiten
        width: 1/3
            type: pages
            label: Navigation
            label: Öffnungszeiten
            type: textarea
    label: Popup
    icon: alert
        label: Popup aktivieren
        type: toggle
        label: Titel
        type: text
        label: Text
        type: textarea
        label: Ok Button Text
        type: text  
    label: Einstellungen
    icon: cog
        width: 2/3
        width: 1/3
            type: fields
            headline: Einstellungen
                label: Logo
                type: files
                label: favicon
                type: files
                label: Google Analytics
                type: textarea
                buttons: false
                font: monospace
                size: small

I still get the 510 Error:
POST http://mydomain.ch/api/site 510 (Not Extended)

…and the following Error:
Error: The JSON response from the API could not be parsed. Please check your API connection. at app.js:1 at l (vendor.js:17) at Generator._invoke (vendor.js:17) at Generator.next (vendor.js:17) at r (vendor.js:6) at s (vendor.js:6)

Thanks for any kind of help!

To clarify this a bit more:

It seems to me, this error only happens with some fields but not with all? Or does this happen no matter which field you try to save?

In the beginning of this thread, it seems that the issue only appeared in another blueprint. Is that fixed now? Or is it irrelevant and the issue pops up independent of what blueprint is used?

Is the Kirby version still 3.4.5 or have you updated in the meantime?

Does the server setup meet Kirby’s requirement, especially regarding the required extensions?

And also: Can you reproduce your issue in a fresh Starterkit?

It may help, when in the panel, to open the developer tools in your browser, open the network tab and then save the page to get the error. The POST request should appear as a (probably red) entry in the list of network requests. If you click on it you should see some tabs and one with the (json) response. Maybe this can give a clue on what’s wrong.

1 Like

Thanks, I just updated to version 3.5 and then tried it all again.
Now after saving I see the response (error) of the POST request even in the panel displayed

Response content:

Access denied by security policy
    Your request is blocked by a security policy rule.
    Please contact the support team and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

EDIT: Actually now, after reproducing the error several times it suddenly works, I’m not sure what solved the problem but the server now accepts saving the changes.

EDIT2: And with another field type “file” the error reappeared again. It has to do with the ModSecurity settings of my hoster, it gets trapped there so I had to change some rules now it works…