You are trying to use API_BILLING_DOCUMENT_SRV to cancel a Billing document however faces error message: 'Precondition required".
S/4HANA Cloud all versions
The error message "Precondition required" indicates that you did not pass an Etag when posting the request. Kindly read the business documentation for further info.
To ensure that you process the latest version of a billing document, you have to use the ETag handling feature that is implemented using the LastChangeDateTime property in the A_BillingDocument node. To retrieve the ETag value for a billing document, perform a GET operation on the LastChangeDateTime property. This value can then be used when triggering a cancel action.
KBA , SD-BIL-IV , Processing Billing Documents , How To