'Bad Request' when creating a funding source


(Ibraheem Ibraheem) #1

Hello there,

Reference: https://developers.dwolla.com/guides/transfer-money-between-users/03-attach-unverified-bank.html

I have tried to create a (unverified) funding source and attach it to a customer as outlined in the above link.

What works:
Creating a customer. The response to the request is
{StatusCode: 201, ReasonPhrase: ‘Created’ …Location: Location: https://api-uat.dwolla.com/customers/9553e503-9afb-4451-b6ac-2c97399603a8}

What doesn’t work: creating a funding source for the customer

Code Snippet (C#):

            try
            {

                client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", app_config.dwolla_access_token);
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(app_config.accept_header));
                string requestUri = (app_config.dwolla_sandbox ? app_config.dwolla_sandbox_host : app_config.dwolla_production_host) + endpoint;
                StringContent sc = new StringContent(Jss.Serialize(parameters), Encoding.UTF8, app_config.dwolla_content_type);
                HttpResponseMessage request = client.PostAsync(requestUri,sc).Result; 

                return request;
            }
            catch (Exception err)
            {
                Console.WriteLine("dwolla.net: An exception has occurred while making a POST request.");
                Console.WriteLine(err.ToString());
                return null;
            }

When attempting to creating a funding source

The URL i’m posting to when creating a funding source for the customer at run time:

https://api-uat.dwolla.com/customers/79bb3660-85f8-4074-952b-45fec8a40f66/funding-sources

The parameters i’m serializing are:
accountNumber = “9898978761”;
routingNumber = “02100000045”;
typ = “checking”;
name = “JP Morgan Chase n Co.”;

The response i’m getting back is

{StatusCode: 400, ReasonPhrase: ‘Bad Request’, Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
{
IsSuccessStatusCode false bool
ReasonPhrase “Bad Request” string
RequestMessage {Method: POST, RequestUri: ‘https://api-uat.dwolla.com/customers/79bb3660-85f8-4074-952b-45fec8a40f66/funding-sources’,…}
}

I’d like to know if
A) The instructions provided above still valid

B) If the instructions are current, am I posting to the wrong URL? Or are the parameters i’m passing wrong?

Best Regards,
Ibraheem


(Spencer Hunter) #2

Everything looks correct with regards to the steps you are following and the request URL. It may be an issue with the request body you are sending. Are you able to output the raw JSON request body that is getting sent do the Dwolla API? Also, we do a validation check on the routing number to determine if it is accurate. Try updating your routing number to using either 222222226 or a real routing number.


(Ibraheem Ibraheem) #3

Thank you Spencer! It did turn out to be the routing number. The funding source does get created when I provide a real routing number.

Thanks a lot for your help.