Repository navigation
Send the SOAP request as UTF-8 bytes with a charset - #25
Merged
Merged
Conversation
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.
antoniospneto
force-pushed
the
main-fix-utf8-request
branch
from
October 6, 2026 01:34
cbb705d to
e9f9c3e
Compare
rvalyi
approved these changes
Oct 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
O content-type do xsdata (
text/xml) vai sem charset, e o payload ia prorequestscomostr. Com o urllib3 1.x (fixado pelo Odoo 16), ohttp.clientcodifica esse corpo em ISO-8859-1; com o urllib3 2.x o corpo já vai em UTF-8, mas semcharsetno 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-8autoriza (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