ApiException in ApiClient.php line 315: [400] Error connecting to the API (https://api-sandbox.dwolla.com/customers)

(SP) #1

I am trying to create new Verified Business Customer (businessType= llc, corporation or partnership) using same example of https://docs.dwolla.com/#create-a-customer in Laravel 5.2 But having error Error connecting to the API

If I try to create customer verified business Customer (sole proprietorship only) is working proper.

Even If I try to get list of customers using https://docs.dwolla.com/#retrieve-a-customer , its working fine.

Is there any different role base access of Verified Business Customer (businessType= llc, corporation or partnership) and verified business Customer (sole proprietorship only) ?

Please help me regarding.

(SP) #2

Found issue in API documentation address2 field is require to create Verified Business Customer (businessType= llc, corporation or partnership)

(Shreya Thapa) #3

Hi @shreyas.p, I was able to create both types of Verified Business Customers with and without the address2 field, which makes me wonder if the issue lies somewhere else? Would you mind sharing the original request-body that was returning the error?

(SP) #4

@shreya

Thanks for your reply.

Now its working proper. The issue was with other field. But I have an question is why error handling is not proper upon require fields?

Like, If I skip any other require field “firstName”, they error should show “First Name is require”, same way like DOB format is invalid etc.

Every time I am getting same error like ApiException in ApiClient.php line 315: [400] Error connecting to the API (https://api-sandbox.dwolla.com/customers) , when something wrong in fields

(Shreya Thapa) #5

Hi @shreyas.p,

You should be able to catch the error and get the JSON response-body. You can try wrapping the request in a try/catch and display the error response by calling the getResponseBody() method.

Example:

try{
    $new_customer = $customersApi->create([
        //request_body   
    ]);
} catch (Exception $e) {
    echo 'Caught exception: ',  $e->getResponseBody(), "\n";
}
(SP) #6

Hi @shreya

Please check the following screencast for the same.

Still having issue. Sometime it works sometime showing such error.

Having issue with creating new customer.
I can connect to api as well as get customers list too.
I also used the same try catch for following data.

{

“firstName”:“my first name”,
“lastName”:“my last name”,
“email”:"test@myanydomain.com",
“type”:“business”,
“address1”:“street address line number one”,
“address2”:“street address line number two”,
“city”:“city name”,
“state”:“AL”,
“postalCode”:“10001”,
“controller”:{
“firstName”:“my first name2”,
“lastName”:“my last name1”,
“title”:“Mr1”,
“dateOfBirth”:“2014-08-08”,
“ssn”:“1234”,
“address”:{
“address1”:“street address line number one”,
“address2”:“street address line number two”,
“city”:“city name”,
“stateProvinceRegion”:“AL”,
“postalCode”:“10001”,
“country”:“US”
}
},
“businessClassification”:“9ed3f671-7d6f-11e3-803c-5404a6144203”,
“businessType”:“llc”,
“businessName”:“business name”,
“ein”:“12-1111111”,
“doingBusinessAs”:“any”
}

(SP) #7

:roll_eyes: Found issue of DateofBirth

Same format as your documentation “2014-08-08”.
But once I entered 1980-10-10 far date. it worked.

There should be DOB related validation if age restriction or anything

(Shreya Thapa) #8

Hi @shreyas.p, thanks for following up with the resolve for the issue!

We do have a restriction on the age for users in Dwolla; they must be 18 years or older. When creating a Customer account with a dateOfBirth that doesn’t fit the range of eligible values, the response body would include an error message as follows,

{
  "code": "ValidationError",
  "message": "Validation error(s) present. See embedded errors list for more details.",
  "_embedded": {
    "errors": [{
      "code": "NotAllowed",
      "message": "DateOfBirth value not allowed.",
      "path": "/dateOfBirth",
      "_links": {}
    }]
  }
}

For any other validation errors with the dateOfBirth field (e.g. invalid format: 12-31-1999), the response would include the following error message,

{
  "code": "ValidationError",
  "message": "Validation error(s) present. See embedded errors list for more details.",
  "_embedded": {
    "errors": [{
      "code": "InvalidFormat",
      "message": "DateOfBirth invalid.",
      "path": "/dateOfBirth",
      "_links": {}
    }]
  }
}

That being said, I can definitely circle back with our team on including more descriptive error messages to responses from the API. Thanks for the feedback! Please let us know if you come across any questions!