rjkmelb
1
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
Any attempt to save the data results in
Path not found
However
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.
artur
2
Hi!
http://myapi.com/api/collections/save/post
do you also provide a data object?
rjkmelb
3
Do you mean JSON for each of the fields I want to update? If so, yes.
artur
4
So your request looks like this:
fetch('/api/collections/save/posts?token=xxtokenxx', {
method: 'post',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
data: {
fieldA: 'x',
fieldB: 'y'
}
})
});
?
rjkmelb
5
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;
}
artur
6
can you try this:
$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"
}
}');
rjkmelb
7
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.
esisl
8
And me too
What and where to look?