Bad Request initiating a transfer via PHP guzzle

I have read through a bunch or BadRequest posts in here and have yet to find an a way to resolve my issue.

$initiateTransferReq = $guzzle->request('POST', 'https://api-sandbox.dwolla.com/transfers', [
				'headers' => [
					'Accept' => 'application/vnd.dwolla.v1.hal+json',
					'Content-Type' => 'application/json',
			    	'Authorization' => 'Bearer '. $token->access_token
			    ],
			    'json' => [
				    "_links" => [
					   	"source" => [
					       	"href" => $originating
					   	],
					   	"destination" => [
					       	"href" => $destination
					   	]
					],
					"amount" => [
					   "currency" => "USD",
					   "value" => "10.00"
					]
				]
			]
		);

This is spitting back a 400 error:
#message: “”"
Client error: POST https://api-sandbox.dwolla.com/transfers resulted in a 400 Bad Request response:
{“code”:“BadRequest”,“message”:“The request body contains bad syntax or is incomplete.”}
“”"
#code: 400

My token is good, my originating and destination urls are good. any ideas?

Hi @tjsherrill, thanks for posting! There should be a response header called X-Request-Id. Are you able to share what that is or any additional information that will help us look up the request? We can look up the raw request to see what’s getting sent over the wire.

Thanks @spencer. Here it is:

  "X-Request-Id" => array:1 [▼
    0 => "c37e08fa-45ba-4adf-9be0-7bb8a36a5604"
  ]

Hi @tjsherrill, It looks like you just need a small tweak to your request body. It looks like theres an incorrect source link that may be throwing off the request.

{
    "_links": {
        "source": {
            "href": "https://api-sandbox.dwolla.com/accounts/6639e854-5abc-478a-be64-71cd4d3feb27"
        },
        "destination": {
            "href": "https://api-sandbox.dwolla.com/funding-sources/0dd4e851-9939-4c3a-a2d7-b16f9d1645d9"
        }
    },
    "amount": {
        "currency": "USD",
        "value": "10.00"
    }
}

You’ll just need to update the source URL from /accounts/6639e854-5abc-478a-be64-71cd4d3feb27 to a Funding Source URL /funding-sources/{id}. This would be a funding source ID that belongs to the account that you want to send from. If you want to send from an attached bank, then you could use /funding-sources/1a0bf788-af42-401c-81e4-1dbcc46f1faf. This can be found by calling the API to retrieve your Account’s List of Funding Sources.

Hope this helps, please don’t hesitate to reach out if you run into anything else!

Thanks a ton. This makes sense. My use case is that I plan to pay members of the site I am building based on things they do so the goal is that the funds come from the primary dwolla account balance.

As a follow up I am call the root api and trying to get my account funding source as the one that is payout out. But there is no funding_sources array coming back:

{#2191
+"_links": {#2186
+“webhook-subscriptions”: {#2185
+“href”: “link”
+“type”: “application/vnd.dwolla.v1.hal+json”
+“resource-type”: “webhook-subscription”
}
+“notifications-settings”: {#2187
+“href”: “link”
+“type”: “application/vnd.dwolla.v1.hal+json”
+“resource-type”: “notifications-settings”
}
+“account”: {#2188
+“href”: “link”
+“type”: “application/vnd.dwolla.v1.hal+json”
+“resource-type”: “account”
}
+“customers”: {#2189
+“href”: “link”
+“type”: “application/vnd.dwolla.v1.hal+json”
+“resource-type”: “customer”
}
+“events”: {#2190
+“href”: “link”
+“type”: “application/vnd.dwolla.v1.hal+json”
+“resource-type”: “event”
}
}
}

Any insight you can provide there?

You’ll want to make a GET https://api-sandbox.dwolla.com/accounts/6639e854-5abc-478a-be64-71cd4d3feb27/funding-sources. You should be able to obtain your Account URL from calling the root of the API. Within that response, there will be an _embedded list of funding-sources where you should see the Funding Source URL that represents your balance.