I am new to Plone Restapi, but I have found that this works:
final http.Response response = await http.post(
'https://mysite.no/@login',
headers: <String, String>{
'Accept': 'application/json',
'Content-Type': 'application/json',
},
body: jsonEncode(
<String, String>{
'login': username,
'password': password,
},
),
);
And returns the token
var myToken = json.decode(response.body)['token'];
And I can add a document with:
final http.Response xresponse = await http.post(
'https://mysite.no/',
headers: <String, String>{
'Authorization': 'Bearer $myToken',
'Accept': 'application/json,',
'Content-Type': 'application/json'
},
body: jsonEncode(
<String, String>{"@type": "Document", "title": "My Document"},
),
);
If I try to search the site,
http.post(
'https://mysite.no/@search',
Gives me message": "Resource not found: https://mysite.no/@search",
Am I missing something obvious?