admin管理员组文章数量:1122846
I'm trying to send a GET request to my Odoo API endpoint using Postman, but I'm encountering a "403 Forbidden" error. Here are the details of my setup:
Odoo Version: [ Odoo 15 community]
API Endpoint:
http://localhost:8069/api/postman
Authentication: I'm using Basic Authentication with the following credentials:
Username: [admin] it is my odoo username
Password: [ admin] it is my odoo password
This is the full error message I receive when I click send: xml
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>403 Forbidden</title>
<h1>Forbidden</h1>
<p>You don't have the permission to access the requested resource. It is either read-protected or not readable by the server.</p>
Here’s the relevant part of my Odoo controller where I defined the route:
# -*- coding: utf-8 -*-
from odoo import http
class TestApi(http.Controller):
@http.route("/api/postman", methods=["GET"], type="http", auth="basic", csrf=False)
def test_endpoint(self):
return "This is a test API endpoint with basic authentication."
Steps I’ve Taken:
I have verified that my user credentials are correct.
The user has the necessary permissions to access the API.
The API endpoint is correctly configured to use Basic Authentication.
I'm trying to send a GET request to my Odoo API endpoint using Postman, but I'm encountering a "403 Forbidden" error. Here are the details of my setup:
Odoo Version: [ Odoo 15 community]
API Endpoint:
http://localhost:8069/api/postman
Authentication: I'm using Basic Authentication with the following credentials:
Username: [admin] it is my odoo username
Password: [ admin] it is my odoo password
This is the full error message I receive when I click send: xml
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>403 Forbidden</title>
<h1>Forbidden</h1>
<p>You don't have the permission to access the requested resource. It is either read-protected or not readable by the server.</p>
Here’s the relevant part of my Odoo controller where I defined the route:
# -*- coding: utf-8 -*-
from odoo import http
class TestApi(http.Controller):
@http.route("/api/postman", methods=["GET"], type="http", auth="basic", csrf=False)
def test_endpoint(self):
return "This is a test API endpoint with basic authentication."
Steps I’ve Taken:
I have verified that my user credentials are correct.
The user has the necessary permissions to access the API.
The API endpoint is correctly configured to use Basic Authentication.
2 Answers
Reset to default 1Your problem is the auth="basic". This is not a recognised authentication method for Odoo. Odoo's @http.route only accepts 'user', 'public' or 'none'. You can check the usage documentation on odoo/odoo/http.py:route() method.
Erase in odoo doesn'T really support the authentication you want. This code just isn't there. The ode has its own authentication option. When you set "user" it turns on. It consists in the fact that you must first receive a cookie. And then in the postman already pass these cookies in the cookie header. I am sending examples of authentication and subsequent requests from my mobile app. I think it will be clear to you and you will transfer it to the postman. next how use this cookie So you can'T get the data in one request. First you need to get a cookie(token). And then make a request with this cookie. Also note that cookies also come in the set-cookie header By the way, there is another alternative option to create an API KEY in the user's settings and use it. If you want implement basic auth on your custom controller you should do like this. This is my implementation of the basic.
本文标签:
版权声明:本文标题:python - Receiving "403 Forbidden" Error When Sending API GET Request in Odoo Using Postman - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736308289a1933608.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论