콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
1 회신
713 화면

Hello,

I'm developing an app which requires getting PDF of invoices from External API.


I'm able to generate a download link using account.move.action_invoice_download_pdf method, but it only works with a logged user within a web browser, if i get this url via postman, I receive the login page html.


I tried to add the bearer token in the Authorization header, it doesn't work.


So I'd like to know if there is a method which allows to directly download a report/pdf via API.

I tried acount.move.action_print_pdf, I receive 

{

"jsonrpc": "2.0",

"id": null,

"result": {

"context": {

"active_ids": [

161

]

},

"data": null,

"type": "ir.actions.report",

"report_name": "account.report_invoice_with_payments",

"report_type": "qweb-pdf",

"report_file": "account.report_invoice_with_payments",

"name": "Facture PDF"

}

}


then I try ir.actions.report.report_action like this: 


{

  "jsonrpc": "2.0",

  "method": "call",

  "params": {

    "service": "object",

    "method": "execute",

    "args": [

      "{{ _.db_name }}",

      2,

      "{{ _.api_key }}",

      "ir.actions.report",

      "report_action",

[161]

,  { "model": "account.move" },

"account.report_invoice_with_payments"

    ]

  }

}



But I receive the error message: "cannot access local variable 'active_ids' where it is not associated with a value"

There is not documentation explaining how to do that, I'm reading the GitHub but still didn't find any solution...


아바타
취소

Bonjour,

 

Merci pour votre message.

 

Je suis actuellement absent et prendrai connaissance de votre mail à mon retour, le 8 mai 2025.

 

En cas d’urgence, vous pouvez contacter le support :

<![if !supportLists]>·<![endif]>par téléphone au 071/36.60.62

<![if !supportLists]>·<![endif]>par mail à l'adresse suivante : support@mhc.be

 

Merci de votre compréhension.

 

Bien à vous.

 

Julien Durieux - MHCONSULTANTS

 

베스트 답변

That's expected behavior.

The endpoint is designed to work within a logged-in web session. If you're accessing it via Postman or another external client, you first need to authenticate.

By default, Odoo uses session-based authentication, which means it expects a valid user session (i.e., cookie-based, from a browser login). Simply providing a bearer token won't work unless you’ve implemented a proper token-based authentication mechanism.

If you want to call this API from an external system, here are a few approaches:

  1. Use session authentication: First log in to Odoo using a POST request to /web/session/authenticate, get the session ID from the response, and use that in subsequent requests via the Cookie header.
  2. Implement token-based access: You can expose your own controller (using @http.route) and implement token-based authentication logic, or use a module like Restful API (by OCA) that supports token-based auth.
아바타
취소
관련 게시물 답글 화면 활동
1
6월 25
993
3
3월 25
1879
2
2월 25
4503
1
2월 25
1587
1
5월 25
1144