Skip to content

Send the SOAP request as UTF-8 bytes with a charset - #25

Merged
rvalyi merged 1 commit into
akretion:mainfrom
Engenere:main-fix-utf8-request
Oct 7, 2026
Merged

rvalyi merged 1 commit into
akretion:mainfrom
Engenere:main-fix-utf8-request

Conversation

@antoniospneto

@antoniospneto antoniospneto commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

O content-type do xsdata (text/xml) vai sem charset, e o payload ia pro requests como str. Com o urllib3 1.x (fixado pelo Odoo 16), o http.client codifica esse corpo em ISO-8859-1; com o urllib3 2.x o corpo já vai em UTF-8, mas sem charset no content-type a SEFAZ rejeita do mesmo jeito (testado). A SEFAZ lê os acentos errado e rejeita qualquer NF-e assinada que tenha acento com 297 – Assinatura difere do calculado. Este PR codifica o corpo explicitamente em UTF-8 e declara o charset.

Achado testando a OCA/l10n-brazil#4147 em homologação na SVRS. Mesma NF-e base: pelo erpbrasil.edoc autoriza; pela nfelib 3.0.0 + brazil-fiscal-client 0.3.0 dá 297; com corpo UTF-8 e charset=utf-8 autoriza (cStat 100). Mudar o namespace do envelope ou o SOAPAction não fez diferença. Testado ponta a ponta com o código desta branch: NF-e autorizada na SVRS de homologação.

🤖 Generated with Claude Code

The payload was posted as a str: http.client encodes it as ISO-8859-1
while the XML declares UTF-8, and the xsdata content type (text/xml)
carries no charset. SEFAZ then reads accented characters wrongly and
rejects any signed NF-e containing them with cStat 297 (Assinatura
difere do calculado).

Encode the body as UTF-8 and declare charset=utf-8 in the content type.
Checked against the SVRS homologation environment: an NF-e with
accented text went from cStat 297 to cStat 100 (authorized) with this
encoding and header.
@rvalyi
rvalyi merged commit c0ad04a into akretion:main Oct 7, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants