const handleSubmit = async (e) => {
e.preventDefault();
const response = await axios.post(
"http://localhost/web/session/authenticate",
{
jsonrpc: "2.0",
method: "call",
id: 1,
params: {
login: `${login.email}`,
password: `${login.password}`,
db: "odoo",
context: {},
},
},
{
headers: {
"Content-Type": "application/json",
},
},
{ withCredentials: true }
);
console.log("response", response);
};
I am using React, and trying to call Odoo-15 APIs. This is how I successfully call authenticate on my local Odoo-15 and it automatically sets the session-id in cookies.
const getTasks = async () => {
const response = await axios.post("http://localhost/web/dataset/search_read", {
headers: {
"Content-Type": "application/json",
},
credentials: "include",
body: JSON.stringify({
jsonrpc: "2.0",
method: "call",
id: 1,
params: {
model: "res.users",
fields: ["id", "user_id", "name", "state"],
domain: [],
offset: 0,
limit: 0,
sort: "id ASC",
context: {
lang: "en_US",
tz: "Europe/Brussels",
uid: 1,
},
},
}),
})
Now, I tried to get the some records but it gave this error
to load resource: the server responded with a status of 404 ()