Error in Initiating Transfers: Bad Request (Request has bad syntax or is incomplete)

Hello! I’m using Braintree for front-end transactions (credit/debit Drop-In UI) and Dwolla for back-end payouts via ACH (with a facilitator fee). When I try to initiate a transfer via my Python API, I’m getting this error printed:

dwollav2.error.BadRequestError: {"code":"BadRequest","message":"The request body contains bad syntax or is incomplete."}

However, I printed the full request body and found that it contains all required parameters and is formatted correctly. What else usually causes this error? Here is what I do in my API:

					    # Using dwollav2 - https://github.com/Dwolla/dwolla-v2-python 
						request_body = {
							'_links': {
								'source': {
									'href': 'https://api-sandbox.dwolla.com/funding-sources/{my_dwolla_funding_source_id}'
								},
								'destination': {
									'href': dest
								}
							},
							'amount': {
								'currency': 'USD',
								'value': amount
							},
							'fees':[
								{
									'_links': {
										'charge-to': {
											'href': dest
										}
									},
									'amount':{
										"value":feeAmount,
										'currency':'USD'
									}
								}
							]
						}

						transfer = app_token.post('transfers', request_body)
						transfer.headers['location'] 
						print(request_body)

Hi @jbapps – I’m assuming that the “dest” variable holds the funding-source href for the destination. If so, it may be the charge-to field being supplied the same funding-source href that’s causing the error.

The charge-to field expects a “customer” resource href of the party who is being charged the fee.

Would you be able to to give it a try and let us know if replacing that resolves the error?

Thanks!

Ah, yep that looks like that’s the cause! Thank you!!

1 Like