# Path not found / 404 on /api/collections/save

**URL:** <https://discourse.getcockpit.com/t/path-not-found-404-on-api-collections-save/420>\
**Category:** Uncategorized\
**Created:** [November 23, 2018, 6:53am UTC](https://discourse.getcockpit.com/t/path-not-found-404-on-api-collections-save/420 "2018-11-23T06:53:56Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![rjkmelb](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/rjkmelb/32/169_2.png) [@rjkmelb](https://discourse.getcockpit.com/u/rjkmelb)\
**Post date:** [November 23, 2018, 6:53am UTC](https://discourse.getcockpit.com/t/path-not-found-404-on-api-collections-save/420/1 "2018-11-23T06:53:56Z")

</div>

I can get data from a collection using the user token, however I cannot do this:

[http://myapi.com/api/collections/save/posts?token=mytoken](http://myapi.com/api/collections/save/posts?token=mytoken)

Any attempt to save the data results in

Path not found

However

[http://myapi.com/api/collections/get/posts?token=mytoken](http://myapi.com/api/collections/get/posts?token=mytoken)

will return JSON data.

I have my headers set to Content-Type application/json

and the body of the request is in valid JSON.

any ideas appreciated.

---

<div class="post-metadata">

**Author:** ![artur](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/artur/32/4_2.png) [@artur](https://discourse.getcockpit.com/u/artur)\
**Post date:** [November 23, 2018, 10:19am UTC](https://discourse.getcockpit.com/t/path-not-found-404-on-api-collections-save/420/2 "2018-11-23T10:19:37Z")

</div>

Hi!

```auto
http://myapi.com/api/collections/save/post

```

do you also provide a data object?

---

<div class="post-metadata">

**Author:** ![rjkmelb](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/rjkmelb/32/169_2.png) [@rjkmelb](https://discourse.getcockpit.com/u/rjkmelb)\
**Post date:** [November 23, 2018, 10:30am UTC](https://discourse.getcockpit.com/t/path-not-found-404-on-api-collections-save/420/3 "2018-11-23T10:30:25Z")

</div>

Do you mean JSON for each of the fields I want to update? If so, yes.

---

<div class="post-metadata">

**Author:** ![artur](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/artur/32/4_2.png) [@artur](https://discourse.getcockpit.com/u/artur)\
**Post date:** [November 23, 2018, 10:50am UTC](https://discourse.getcockpit.com/t/path-not-found-404-on-api-collections-save/420/4 "2018-11-23T10:50:06Z")

</div>

So your request looks like this:

```auto
fetch('/api/collections/save/posts?token=xxtokenxx', {
    method: 'post',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({
        data: {
          fieldA: 'x',
          fieldB: 'y'
        }
    })
});

```

?

---

<div class="post-metadata">

**Author:** ![rjkmelb](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/rjkmelb/32/169_2.png) [@rjkmelb](https://discourse.getcockpit.com/u/rjkmelb)\
**Post date:** [November 23, 2018, 10:56am UTC](https://discourse.getcockpit.com/t/path-not-found-404-on-api-collections-save/420/5 "2018-11-23T10:56:37Z")

</div>

Looks like this:

```
        <?php

$request = new HttpRequest();
$request->setUrl('http://myapi.com/api/collections/save/docs');
$request->setMethod(HTTP_METH_POST);

$request->setQueryData(array(
  'token' => ' **mytoken**'
));

$request->setHeaders(array(
  'Content-Type' => 'application/json'
));

$request->setBody('{
    "description": "This is a test entry",
    "thumbnailurl": "https://myblog.com/images/image.jpg",
    "contenturl": "none",
    "hostPageurl": "http://myblog.com/pages/page.html",
    "encodingformat": "jpeg"
}');

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
```

---

<div class="post-metadata">

**Author:** ![artur](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/artur/32/4_2.png) [@artur](https://discourse.getcockpit.com/u/artur)\
**Post date:** [November 23, 2018, 11:05am UTC](https://discourse.getcockpit.com/t/path-not-found-404-on-api-collections-save/420/6 "2018-11-23T11:05:26Z")

</div>

> [@rjkmelb](#):
>
> $request-\>setBody(‘{ “description”: “This is a test entry”, “thumbnailurl”: “[https://myblog.com/images/image.jpg](https://myblog.com/images/image.jpg)”, “contenturl”: “none”, “hostPageurl”: “[http://myblog.com/pages/page.html](http://myblog.com/pages/page.html)”, “encodingformat”: “jpeg” }’);

can you try this:

```auto
$request->setBody('{
    "data": {
      "description": "This is a test entry",
      "thumbnailurl": "https://myblog.com/images/image.jpg",
      "contenturl": "none",
      "hostPageurl": "http://myblog.com/pages/page.html",
      "encodingformat": "jpeg"
    }
}');

```

---

<div class="post-metadata">

**Author:** ![rjkmelb](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/rjkmelb/32/169_2.png) [@rjkmelb](https://discourse.getcockpit.com/u/rjkmelb)\
**Post date:** [November 23, 2018, 11:09am UTC](https://discourse.getcockpit.com/t/path-not-found-404-on-api-collections-save/420/7 "2018-11-23T11:09:21Z")

</div>

Same result. I am beginning to think it’s the way I installed Cockpit.

I am going to fire up a docker standard install instance, then replicate the table and try it again. Thanks for your help so far.

---

<div class="post-metadata">

**Author:** ![esisl](https://avatars.discourse-cdn.com/v4/letter/e/94ad74/32.png) [@esisl](https://discourse.getcockpit.com/u/esisl)\
**Post date:** [July 2, 2019, 12:19pm UTC](https://discourse.getcockpit.com/t/path-not-found-404-on-api-collections-save/420/8 "2019-07-02T12:19:27Z")

</div>

And me too ☹  
What and where to look?
