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

**URL:** <https://discuss.dwolla.com/t/apiexception-in-apiclient-php-line-315-400-error-connecting-to-the-api-https-api-sandbox-dwolla-com-customers/5182>\
**Category:** API Support\
**Created:** [May 12, 2019, 5:38am UTC](https://discuss.dwolla.com/t/apiexception-in-apiclient-php-line-315-400-error-connecting-to-the-api-https-api-sandbox-dwolla-com-customers/5182 "2019-05-12T05:38:45Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![shreyas.p](https://avatars.discourse-cdn.com/v4/letter/s/a183cd/32.png) [@shreyas.p](https://discuss.dwolla.com/u/shreyas.p)\
**Post date:** [May 12, 2019, 5:38am UTC](https://discuss.dwolla.com/t/apiexception-in-apiclient-php-line-315-400-error-connecting-to-the-api-https-api-sandbox-dwolla-com-customers/5182/1 "2019-05-12T05:38:45Z")

</div>

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](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](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.

---

<div class="post-metadata">

**Author:** ![shreyas.p](https://avatars.discourse-cdn.com/v4/letter/s/a183cd/32.png) [@shreyas.p](https://discuss.dwolla.com/u/shreyas.p)\
**Post date:** [May 12, 2019, 6:32am UTC](https://discuss.dwolla.com/t/apiexception-in-apiclient-php-line-315-400-error-connecting-to-the-api-https-api-sandbox-dwolla-com-customers/5182/2 "2019-05-12T06:32:03Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![shreya](https://sea2.discourse-cdn.com/dwolla/user_avatar/discuss.dwolla.com/shreya/32/2154_2.png) [@shreya](https://discuss.dwolla.com/u/shreya)\
**Post date:** [May 13, 2019, 3:33pm UTC](https://discuss.dwolla.com/t/apiexception-in-apiclient-php-line-315-400-error-connecting-to-the-api-https-api-sandbox-dwolla-com-customers/5182/3 "2019-05-13T15:33:32Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![shreyas.p](https://avatars.discourse-cdn.com/v4/letter/s/a183cd/32.png) [@shreyas.p](https://discuss.dwolla.com/u/shreyas.p)\
**Post date:** [May 14, 2019, 8:28am UTC](https://discuss.dwolla.com/t/apiexception-in-apiclient-php-line-315-400-error-connecting-to-the-api-https-api-sandbox-dwolla-com-customers/5182/4 "2019-05-14T08:28:55Z")

</div>

@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)](https://discuss.dwolla.com/t/apiexception-in-apiclient-php-line-315-400-error-connecting-to-the-api-https-api-sandbox-dwolla-com-customers/5182)** , when something wrong in fields

---

<div class="post-metadata">

**Author:** ![shreya](https://sea2.discourse-cdn.com/dwolla/user_avatar/discuss.dwolla.com/shreya/32/2154_2.png) [@shreya](https://discuss.dwolla.com/u/shreya)\
**Post date:** [May 14, 2019, 4:47pm UTC](https://discuss.dwolla.com/t/apiexception-in-apiclient-php-line-315-400-error-connecting-to-the-api-https-api-sandbox-dwolla-com-customers/5182/5 "2019-05-14T16:47:59Z")

</div>

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:

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

```

---

<div class="post-metadata">

**Author:** ![shreyas.p](https://avatars.discourse-cdn.com/v4/letter/s/a183cd/32.png) [@shreyas.p](https://discuss.dwolla.com/u/shreyas.p)\
**Post date:** [May 15, 2019, 11:25am UTC](https://discuss.dwolla.com/t/apiexception-in-apiclient-php-line-315-400-error-connecting-to-the-api-https-api-sandbox-dwolla-com-customers/5182/6 "2019-05-15T11:25:05Z")

</div>

Hi @shreya

Please check the following screencast for the same.

> **[05.15.2019-16.53.50](https://www.screencast.com/t/oRNQPE5g)**
>
> Shared from Screencast.com

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”  
}

---

<div class="post-metadata">

**Author:** ![shreyas.p](https://avatars.discourse-cdn.com/v4/letter/s/a183cd/32.png) [@shreyas.p](https://discuss.dwolla.com/u/shreyas.p)\
**Post date:** [May 15, 2019, 12:00pm UTC](https://discuss.dwolla.com/t/apiexception-in-apiclient-php-line-315-400-error-connecting-to-the-api-https-api-sandbox-dwolla-com-customers/5182/7 "2019-05-15T12:00:21Z")

</div>

🙄 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

---

<div class="post-metadata">

**Author:** ![shreya](https://sea2.discourse-cdn.com/dwolla/user_avatar/discuss.dwolla.com/shreya/32/2154_2.png) [@shreya](https://discuss.dwolla.com/u/shreya)\
**Post date:** [May 15, 2019, 3:58pm UTC](https://discuss.dwolla.com/t/apiexception-in-apiclient-php-line-315-400-error-connecting-to-the-api-https-api-sandbox-dwolla-com-customers/5182/8 "2019-05-15T15:58:00Z")

</div>

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,

```auto
{
  "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,

```auto
{
  "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!
