Error 404 on Save via API

I note a few threads but no one seems to say how they fixed it! Any thoughts
I can /get/ fine but as soon as I try and use /save/ i get a 404 error all the details look good (works to get)

Sample url: https://sever/api/collections/save/PlayerStats?token=token&_id=1&UID=3&Credits=1

Any ideas? I’ve tried on two different servers and get the same outcome.

You have to wrap your field names into data, so this should work:
/api/collections/save/PlayerStats?token=xxtokenxx&data[_id]=1&data[UID]=3

See also: https://getcockpit.com/documentation/api/collections

I get the same result error 404, any other ideas?

Could it be a htaccess issue? With no token provided i get “Unauthorised” but as soon as i supply the key it fails. Adding data[value] gave a 404 as well.

Tried again with a 3rd webserver this time on Lightsail, exactly the same result. If it’s not working with default setups via DO and Lightsail I would say this needs a look at in more detail. I can’t be the only one who hits a brick wall?

That’s by design. You always have to send an api key.

What’s your system (PHP >7, Apache or nginx…)?
Do you use the latest Cockpit version (next branch)?
Which addons do you use?

PHP 7 with Apache via a Bitnami deployment on Lightsail.
I’ve tried both the stable and edge release with the same result. Any attempt to call /save/ results in a 404 if a parameter is sent alongside the token.

No addons installed this is a clean install of cockpit

Maybe I understood your issue now. Do you try to save _id=1 with the numeric “1” or is the “1” a placeholder for a mongodb id. It should look like this: _id=5d271cab33386214e40002ad.
After I tried to save it with the numeric id, I got a 404 as well.

If you try to save a new entry, you don’t have to send a _id with your request. It will be generated automatically.

this is not a MongoDB the ID=1 corresponds to a record I would like to update. I’ve also tried without an id as well and get a 404. It seems as any data is included in the url it throws a 404.

Give it a try spin-up an instance on Lightsail and use the standard install method not a docker and you will see what I mean. Same error on EC2 and Digital Ocean. I think the install info needs updating to include what ever this issue us.

I see what you mean about the mongodb id so I’ve tried as follows and still get a 404

https://domain/api/collections/save/PlayerStats?token&data[_id]=15d26e5ee3035340a82000191&data[credits]=3

I don’t have the time right now to test Amazon Lightsail. Maybe I’ll give it a try in a few days, but I can’t promise.

Do you mean the “next” branch? There is no “edge” - and “legacy” is outdated. I use always the next branch.

I want to be sure, that the issue is not only a typo…

Are you able to save a new entry via backend? It uses nearly the same code, so if that works, you have write permissions and it should work with the api, too.

Did you try to save a very simplified test collection, where you didn’t try to save entries with a numeric id in the preserved _id field?

Does Cockpit work on a local machine like expected?