Trouble Creating a Transfer: [400] Error connecting to the API (https://api-uat.dwolla.com/transfers)


(Rishi Bhat) #1

Hi,

I’m new to the Dwolla API and am trying to get some basic functionality working in my company’s application. We are currently using the co-branded solution (Account). I am trying to create a simple transfer between 2 users of our application, both of whom have verified funding sources. I have been able to successfully send both users through the OAuth authentication flow, and have correctly obtained account access tokens for each, which were then used to retrieve the respective funding sources. However, when I then try to create a transfer (using the sender’s access_token if that matters), I get a 400 error.

Following the example from https://docsv2.dwolla.com/#initiate-a-transfer, here’s the output for the transfer request (outputted using PHP’s print_r function). This is what I’m sending to $transfersApi->create():

Array
(
    [_links] => Array
        (
            [source] => Array
                (
                    [href] => https://api-uat.dwolla.com/funding-sources/131ffdc1-e914-4828-bd16-c89cec682510
                )

            [destination] => Array
                (
                    [href] => https://api-uat.dwolla.com/funding-sources/626b1108-56be-4f8d-bed6-db712acfc006
                )

        )

    [amount] => Array
        (
            [currency] => USD
            [value] => 213
        )

)

As far as I can tell, the data looks to be in the correct format according to the docs. If someone can help, I’d be grateful. Thank you.

P.S. I haven’t yet added the “fees” object to the above, but am planning to do so next. Is there anything I should be aware of as far as adding that? Thanks.


(Spencer Hunter) #2

At first glance, the request looks good to me. Do you have the debug flag enabled for the swagger PHP client? This will hopefully help with returning the actually response body that is returned from the Dwolla API.

Be sure to reference our resource article on facilitator fees for more information. Reference the thread below for a helpful tip as well…


(Rishi Bhat) #3

Hey @spencer -

I tried enabling the debug mode, and I got the following (additional) output:

[DEBUG] HTTP Request body ~BEGIN~
{"_links":{“source”:{“href”:“https://api-uat.dwolla.com/funding-sources/a039d684-a36c-4443-bd37-052716b2c30f"},“destination”:{“href”:“https://api-uat.dwolla.com/funding-sources/626b1108-56be-4f8d-bed6-db712acfc006”}},“amount”:{“currency”:“USD”,“value”:"213”}}
~END~

Warning: curl_setopt(): cannot represent a stream of type Output as a STDIO FILE* in C:\vendor\dwolla\dwollaswagger\lib\ApiClient.php on line 276

[DEBUG] HTTP Response body ~BEGIN~
{“code”:“ValidationError”,“message”:“Validation error(s) present. See embedded errors list for more details.”,"_embedded":{“errors”:[{“code”:“Invalid”,“message”:“Receiver not found.”,“path”:"/_links/destination/href","_links":{}}]}}
~END~

Fatal error: Uncaught exception ‘DwollaSwagger\ApiException’ with message ‘[400] Error connecting to the API (https://api-uat.dwolla.com/transfers)’ in C:\vendor\dwolla\dwollaswagger\lib\ApiClient.php:311

This seems odd to me because I have checked to make sure I’m sending the transfer to the correct destination, which I’m sure is a verified account, yet I still get the “Receiver not found” error. I’ve been banging my head against the wall about this for several days now so any help would be much appreciated. Thanks!


(Spencer Hunter) #4

@Rishi_Bhat, It looks like you’re attempting to send directly to a bank account that is attached to the Dwolla account of the recipient, which isn’t allowed in our co-branded solution. Reference the thread below to see alternative options:


(Rishi Bhat) #5

Thanks @spencer … one more question, is there a way to programmatically set or retrieve the setting for auto-withdrawal (for a particular user)? I see it here for the v1 API: https://docs.dwolla.com/#get-auto-withdrawal-status but I can’t find anything about it in the v2 docs. Is this possible?


(Spencer Hunter) #6

@Rishi_Bhat, There isn’t currently. However, that is something that is still under Product consideration for our latest API.


(Rishi Bhat) #7

Thanks @spencer, is there any way we can continue using this function from v1 of the API? If not, any idea when we might be able to expect that feature?


(Rishi Bhat) #8

@spencer - I tried what you suggested but it’s still not working and I get the same “Receiver not found error”. I’m trying to initiate a transaction from User1 to User2. I’m able to retrieve both their funding sources correctly. I have tried sending from a verified checking account (User1) to the Balance (User2) as well as from User1’s Balance to User2’s Balance. In both cases, I receive the same error. What am I doing wrong here? Also, I am using the access_token obtained by User1 when I try to initiate the transfer. Your help would be much appreciated.

Calling create_transfer for 213 with src: a039d684-a36c-4443-bd37-052716b2c30f and dest: da258544-f897-44d2-b9e5-9c18aa05a2cf

Sending data below to /transfers:

Array
(
[_links] => Array
(
[source] => Array
(
[href] => https://api-uat.dwolla.com/funding-sources/a039d684-a36c-4443-bd37-052716b2c30f
)

        [destination] => Array
            (
                [href] => https://api-uat.dwolla.com/funding-sources/da258544-f897-44d2-b9e5-9c18aa05a2cf
            )
    )
[amount] => Array
    (
        [currency] => USD
        [value] => 213
    )

)
[DEBUG] HTTP Request body ~BEGIN~
{"_links":{“source”:{“href”:“https://api-uat.dwolla.com/funding-sources/a039d684-a36c-4443-bd37-052716b2c30f"},“destination”:{“href”:“https://api-uat.dwolla.com/funding-sources/da258544-f897-44d2-b9e5-9c18aa05a2cf”}},“amount”:{“currency”:“USD”,“value”:"213”}}
~END~

Warning: curl_setopt(): cannot represent a stream of type Output as a STDIO FILE* in C:\vendor\dwolla\dwollaswagger\lib\ApiClient.php on line 276

[DEBUG] HTTP Response body ~BEGIN~
{“code”:“ValidationError”,“message”:“Validation error(s) present. See embedded errors list for more details.”,"_embedded":{“errors”:[{“code”:“Invalid”,“message”:“Receiver not found.”,“path”:"/_links/destination/href","_links":{}}]}}
~END~


(Spencer Hunter) #9

There is no timetable currently for when triggering auto-withdraw on an account may be available in API v2. In the interim, you could call our v1 API just to trigger auto-withdraw for an account. Be sure to request the ManageAccount scope in the initial OAuth authorization request. Alternatively, you could initiate the bank transfer from User A to User B’s account balance, listen for the webhook containing the transfer_completed event, and programmatically initiate the withdraw to the recipient’s attached funding source (Bank account) using User B’s account access token.

It looks like the only thing I see wrong is the destination link in this request. When sending between two Dwolla accounts the destination should always be an Account resource. i.e. https://api-sandbox.dwolla.com/accounts/{someAccountId}. If you update the destination href to be: https://api-sandbox.dwolla.com/accounts/cc582d33-62ea-47a7-a740-39ccf7ea6242 then the request should work. By specifying the account, it should land in this user’s Dwolla account balance if you’re sending to a full Dwolla account.


(Rishi Bhat) #10

Thanks so much, @spencer, I was able to create a transfer successfully finally =).

Quick question: I’m pretty much always using urls of the form http://api-uat.dwolla.com…I noticed in your reply you specified using the destination address as http://api-sandbox.dwolla.com/accounts/{id} - whats the difference between these 2?


(Spencer Hunter) #11

@Rishi_Bhat, We sent out an email communication towards the end of last week regarding a change we’re making to replace “uat” in the subdomain with “sandbox”. Reference this blog post for more information.