gutterboy Posted September 11, 2014 Report Share Posted September 11, 2014 Hello, I'm attempting to edit users via the API and the source docs seem to be lacking a little in this area compared to the create user, so not sure if I have done something wrong...... but I'm basically doing this: if (empty($user_data['country_iso'])) { // We can't pass in a state without a country, so make the state code empty as well $user_data['state_iso'] = ''; } $data = array ( 'client_id' => $user_data['blesta_id'], 'vars' => array ( 'company' => $user_data['tax_company_name'], 'first_name' => $user_data['first_name'], 'last_name' => $user_data['last_name'], 'address1' => $user_data['address'], 'city' => $user_data['city'], 'zip' => $user_data['zip_code'], 'email' => $user_data['email'], 'numbers' => array ( 0 => array ( 'number' => $user_data['phone'] ) ) ) ); if (!empty($user_data['country_iso'])) { // Add country $data['vars']['country'] = $user_data['country_iso']; } if (!empty($user_data['state_iso'])) { // Add country $data['vars']['state'] = $user_data['state_iso']; } $this->api->put("clients", "edit", $data); $this->api points to the Blesta SDK. This is the error output I get back: object(stdClass)[9] public 'error' => object(stdClass)[10] public 'message' => string 'An unexpected error occured.' (length=28) public 'response' => string 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE `id` = '16'' at line 1' (length=219) Am I passing in the data wrong or doing something incorrectly? Is there a way I can make Blesta output the query it is trying to run? Thanks! Quote Link to comment Share on other sites More sharing options...
Tyson Posted September 11, 2014 Report Share Posted September 11, 2014 I'm not sure why you receive an SQL error, but I see the values you're setting for Clients::edit aren't supported by that API call. Sounds like you want Contacts::edit. Quote Link to comment Share on other sites More sharing options...
gutterboy Posted September 11, 2014 Author Report Share Posted September 11, 2014 I'm not sure why you receive an SQL error, but I see the values you're setting for Clients::edit aren't supported by that API call. Sounds like you want Contacts::edit. Hmmm ok. So a client I created with clients::create I need to use contacts::edit and NOT clients::edit to edit their details? Quote Link to comment Share on other sites More sharing options...
Nelsa Posted September 11, 2014 Report Share Posted September 11, 2014 Today I tested virtualizor module and Blesta also give sql syntax error when add/update package but only if set wrong/unknown value for required parameters,I supose you have similar situation. Quote Link to comment Share on other sites More sharing options...
Tyson Posted September 11, 2014 Report Share Posted September 11, 2014 Hmmm ok. So a client I created with clients::create I need to use contacts::edit and NOT clients::edit to edit their details? You can edit a client via Clients::edit, but most information related to a client (e.g. first name, email, address, etc.) belongs to the primary contact. Each client has a contact (i.e. contact type is 'primary'), but it's also possible to add additional contacts under each client. Quote Link to comment Share on other sites More sharing options...
gutterboy Posted September 12, 2014 Author Report Share Posted September 12, 2014 You can edit a client via Clients::edit, but most information related to a client (e.g. first name, email, address, etc.) belongs to the primary contact. Each client has a contact (i.e. contact type is 'primary'), but it's also possible to add additional contacts under each client. Ahh ok, makes sense. Thanks! Quote Link to comment Share on other sites More sharing options...
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.