API call only creates errors, not results

This one’s been doing my head in over the course of this week. I’ve tried the /cockpit/defines.php approach to no avail as well. Printing them out in the login.php looks right to me either way. There’s [COCKPIT_API_REQUEST] => 0 which I couldn’t find explained in the documentation, just that it exists. Should this be somehow set to 1 for on for the to work?

My defines.php

define('COCKPIT_BASE_URL', '/cockpit');
define('COCKPIT_BASE_ROUTE', '/cockpit');
define('COCKPIT_DOCS_ROOT', dirname(__DIR__));

To evaluate Cockpit I’ve set it up locally as I always do with a standard sandboxed MAMP environment.

Below is the error I get when I curl http://localhost:8888/cockpit/api/collections/get/posts?token=account-2771ca3447t6d84dba0c40c4c46625 (the generated token is from an admin user)

From php_error.log

PHP Notice:  Undefined index: admin in /Applications/MAMP/htdocs/cockpit/lib/Lime/App.php on line 1261

I’m looking to use Cockpit to generate Hugo input files, hence I need APIs to work in order to create a tool for doing so (yes, I’m aware of Hugocockpit, but it omits too much of the needed content and can’t be deployed in scenarios where end-users are involved).

Help to get APIs working would be greatly appreciated.

undefined index admin is strange :thinking: do you use any plugins or have custom code anywhere?

Oh hell, warm art thou. :weary:

Thanks for the pointer towards the plugin. I’m so thrilled right now :zipper_mouth_face:. It’s the HugoCockpit plugin. Once deleted, I got the API to respond.

Now that I’ve put the Hugo folder back, I’m getting an additional bit. (I should have thought of that earlier.)

{"error":"Call to a member function addAssets() on null","file":"\/Applications\/MAMP\/htdocs\/cockpit\/addons\/Hugo\/admin.php","line":9}

Thanks again for checking. Should I get this working with the plug-in active, I’ll post an update.

The addon doesn’t check, if it is an api call. If api, than the helper addAssets() doesn’t exist. It should look like this:


Change it here:

And I don’t know, if it works. I tested HugoCockpit a while ago, I had some errors and I never tried it again.

Thank you so much! :blush::relaxed: That did it! I’ve been trying to decipher the what-does-what for a couple of days now.

The biggest error I had with HugoCockpit was that it didn’t output anything. Apache log then revealed the issue. It adds a --canonifyURLs parameter which doesn’t exist. Maybe it did at some point but now it doesn’t. (It’s part of the Hugo config file now.)