Cancel returning invalid response, successful webhook

After sending a request to cancel a payment, I’m receiving a response that the status is not allowed.
I’m using the python library and the request is as follows:

request_body = {'status': 'cancelled'}
app_token.post(transfer_url, request_body)

The response I receive is:

dwollav2.error.ValidationError: {
"code":"ValidationError",
"message":"Validation error(s) present. See embedded errors list for more details.",
"_embedded": 
   {"errors":[{"code":"NotAllowed","message":"Status not allowed.","path":"/status","_links":{}}]}
}

Immediately following this response, I receive a successful webhook:

{
    "id": "8b4dca60-1688-4781-960d-982fa00c9952",
    "resourceId": "b2d80f41-75e7-eb11-8136-b0300d0c7e2a",
    "topic": "customer_transfer_cancelled",
    "timestamp": "2021-07-19T13:20:22.327Z",
    "_links": {
        "self": {
            "href": "https://api-sandbox.dwolla.com/events/8b4dca60-1688-4781-960d-982fa00c9952"
        },
        "account": {
            "href": "https://api-sandbox.dwolla.com/accounts/84cfb86b-54db-44e9-ba91-07968962450c"
        },
        "resource": {
            "href": "https://api-sandbox.dwolla.com/transfers/b2d80f41-75e7-eb11-8136-b0300d0c7e2a"
        },
        "customer": {
            "href": "https://api-sandbox.dwolla.com/customers/aeefa7e4-4025-4fa9-ac38-50e8d560b2bd"
        }
    },
    "created": "2021-07-19T13:20:22.327Z"
}

Hi @jmtichell – thanks for the detailed report!

I checked the logs and actually found a 200 Ok response for cancelling the above transfer in the webhook with the Id b2d80f41-75e7-eb11-8136-b0300d0c7e2a. The request Id for this request was c9204e14-946b-405d-ae98-322f76f06350.

It appears it was a different transfer (Id: b3d80f41-75e7-eb11-8136-b0300d0c7e2a) that returned a 400 error response.

Thank you @shreya , and sorry for the confusion. Do you have any idea why that transfer wasn’t able to be cancelled? I seem to remember having that problem before, but I don’t remember exactly the reason.

Ah yes, it’s a known issue in Sandbox – the last item of a masspayment isn’t able to be canceled even though it has a cancel link. We have a ticket created for a fix in our backlog.

Ok, glad to hear it’s just the final item and not an issue with a malformed request. Thanks again!