Invoice_hashing_errors

{“type”:“ERROR”,“code”:“invalid-invoice-hash”,
“category”:“INVOICE_HASHING_ERRORS”,“message”:“The invoice hash API body does not
match the (calculated) Hash of the XML”,“status”:“ERROR”}

I am getting this error when i am trying to Signin XML with DOTNET DLLs and submiting it to reporting API.
Please can any one list the steps i need to follow to signin BTOC XML using DOTNET DLLs and submit it to reporting API.

Please note that the issue could be only that you are missing some tags to be added in the invoice before submitting it to ZATCA like UBLextension that contains other several tags like the DigestValue (the tag that holds the invoice hash value) So, submitting the invoice decoded as parameter and invoice hash to the API both as JSON request without having a hash value in the decoded invoice, will lead to a mismatch between both of them.

So, please refer to the SDK samples that contains the missing tags,

Also, please follow the steps below to generate the invoice hash:

  1. Load the XML
  2. Remove UBL Extension block
  3. Remove the Signature block (if exists)
  4. Remove the QR block (if exists)
  5. Now you are left with the rest of the XML (this is the hashable portion)
  6. Hash the results using SHA256
  7. Encode the hashed value into Base64 string

make sure when encoding to base64 use hex to base64. and also check the SDK as it’s a provided functionality that.

*Please check the signing process on the technical guidelines (1st step is how to generate the hash):https://zatca.gov.sa/en/E-Invoicing/Introduction/Guidelines/Documents/E-invoicing-Detailed-Technical-Guideline.pdf

when you load your xml set PreserveWhitespace = true

var myXmlDocument = new XmlDocument()
{
PreserveWhitespace = true,
};
myXmlDocument.LoadXml(xml);

1 Like