Search code examples
pythondjangodwolla

Invalid source path /_links/source/href - Django


I have a Dwolla api request I am trying to send and I am getting a path invalid path error that I cant figure out. SO the main error is coming from the request body even though I made sure it is similar to the api docs example with the replacement of my information from the database.

Can anyone help me figure out what is going on and what is causing the error.

Here is the example within the Dwolla api docs:

request_body = {
  '_links': {
    'source': {
      'href': 'https://api-sandbox.dwolla.com/funding-sources/707177c3-bf15-4e7e-b37c-55c3898d9bf4'
    },
    'destination': {
      'href': 'https://api-sandbox.dwolla.com/customers/07D59716-EF22-4FE6-98E8-F3190233DFB8'
    }
  },
  'amount': {
    'currency': 'USD',
    'value': '1.00'
  },
  'metadata': {
    'paymentId': '12345678',
    'note': 'payment for completed work Dec. 1'
  },
  'clearing': {
    'destination': 'next-available'
  },
  'correlationId': '8a2cdc8d-629d-4a24-98ac-40b735229fe2'
}

transfer = app_token.post('transfers', request_body)

Here is the output I am getting from my example of gather informaiton:

{  
   '_links':{  
      'source':{  
         'href':'https://api-sandbox.dwolla.com/funding-sources/..a295c'
      },
      'destination':{  
         'href':'https://api-sandbox.dwolla.com/funding-sources/..ae0fc'
      }
   },
   'amount':{  
      'currency':'USD',
      'value':'15.00'
   },
   'metadata':{  
      'paymentId':'507133793',
      'note':'wild night'
   },
   'clearing':{  
      'destination':'next-available'
   },
   'correlationId':'8a2cdc8d-629d-4a24-98ac-40b735229fe2'
}

here is the exact error that is occuring:

ValidationError at /4/4/add_transaction/
{"code":"ValidationError","message":"Validation error(s) present. See embedded errors list for more details.","_embedded":{"errors":[{"code":"Invalid","message":"Invalid funding source.","path":"/_links/source/href","_links":{}}]}}

Solution

  • Validation Errors should contain an embedded list of errors with a top-level error code, a brief message(description of error), and a path which is a pointer to the field that's invalid. In this instance, there are a few things that can return Invalid funding source. for a sending funding source.

    • Is the status of the funding source "verified"? All funding sources need to have a verified status in order to be eligible to send.
    • Is the URL valid and does it point to a funding source that exists for the user account you have authorization to send from?

    My assumption is that the funding source is "unverified" when in needs to be verified, but check those few things to see if that resolves the error! Reference our docs for more information on funding source verification.