WebhostingNZ.com Posted October 9, 2018 Report Posted October 9, 2018 Hey, Hopefully, someone can help. I am having trouble adding a client via the API, I keep getting the following error: BlestaResponse Object ( [raw:BlestaResponse:private] => {"message":"An unexpected error occured.","response":"Internal error: Failed to retrieve the default value"} [response_code:BlestaResponse:private] => 500 ) My code is as follows: require_once "blesta_api.php"; $user = '***'; $key = '***'; $url = "https://***/api/"; $api = new BlestaApi($url, $user, $key); $data = array( 'username' => 'daniel***.com', 'new_password' => '****', 'confirm_password' => '****', 'client_group_id' => '16', 'status' => 'active', 'first_name' => 'Daniel', 'last_name' => '***', 'title' => 'Mr', 'company' => 'MyCompany', 'email' => 'daniel***.com', 'address1' => '1 street', 'address2' => 'somewhere', 'city' => 'mycity', 'state' => '***', 'zip' => '1111', 'country' => 'NZ', 'numbers' => array ( 'type' => 'phone', 'location' => 'home', 'number' => '****', ), 'settings' => array ( 'username_type' => 'email', 'tax_exempt' => false, 'tax_id' => '', 'default_currency' => 'NZD', 'language' => 'en_us', 'receive_email_marketing' => true, ), 'send_registration_email' => 'true', ); $response = $api->get("clients", "create", $data); print_r($response); Thanks, Daniel Quote
Blesta Addons Posted October 9, 2018 Report Posted October 9, 2018 you should pst request not get $api->post(); Quote
WebhostingNZ.com Posted October 9, 2018 Author Report Posted October 9, 2018 @Blesta Addons Thanks, updated to $response = $api->post("clients", "create", $data); but still get the same error. Quote
WebhostingNZ.com Posted October 10, 2018 Author Report Posted October 10, 2018 Thanks @activa that's not the same problem as I am having though. I am trying to already use clients->create via the API to create the client but am getting an error. Quote
WebhostingNZ.com Posted October 10, 2018 Author Report Posted October 10, 2018 Found my error, a simple one at that. It should be: $data = array( 'vars' => array( 'first_name' => 'Daniel',..... I missed putting in the 'vars' => bit Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.