Jump to content
  • 0

Why Use Api Create Client Return Error?failed To Retrieve The Default Value


Question

Posted

error:

 

post-11272-0-58215000-1443422528_thumb.p

 

 

why this?

<?php
require_once "../blesta/blesta_api.php";

$user = "resller";
$key = "**********";
$url = "http://*********/api/";

$api = BlestaApi::getIns($url, $user, $key);

$json='{"action":"signup","first_name":"\u9676","last_name":"\u96e8","company":"\u6c49\u53e3\u5b66\u9662","address1":"\u6c5f\u590f\u533a\u6587\u5316\u5927\u9053299\u53f7","address2":"16703","city":"\u6b66\u6c49\u5e02","country":"CN","state":"13","zip":"430070","numbers":[{"type":"phone","location":"work","number":"15527474844"},{"type":"fax","location":"work","number":"13396009700"}],"email":"hkxy99@163.com","tax_id":"95599","custom_field1":"424460883","username_type":"email","username":"","new_password":"qaz12345","confirm_password":"qaz12345","client_group_id":"1","settings":{"username_type":"email","tax_id":"95599","default_currency":null,"language":"en_us"},"custom":{"1":"424460883"}}';


$vars=json_decode($json,true);

$response=$api->get('clients','create',$vars);

print_r($response->response());
print_r($response->errors());

data:

json->array:

{"action":"signup","first_name":"\u9676","last_name":"\u96e8","company":"\u6c49\u53e3\u5b66\u9662","address1":"\u6c5f\u590f\u533a\u6587\u5316\u5927\u9053299\u53f7","address2":"16703","city":"\u6b66\u6c49\u5e02","country":"CN","state":"13","zip":"430070","numbers":[{"type":"phone","location":"work","number":"15527474844"},{"type":"fax","location":"work","number":"13396009700"}],"email":"hkxy99@163.com","tax_id":"95599","custom_field1":"424460883","username_type":"email","username":"","new_password":"qaz12345","confirm_password":"qaz12345","client_group_id":"1","settings":{"username_type":"email","tax_id":"95599","default_currency":null,"language":"en_us"},"custom":{"1":"424460883"}}

Error:

Internal error: Failed to retrieve the default valuestdClass Object ( [error] => stdClass Object ( [message] => An unexpected error occured. [response] => Internal error: Failed to retrieve the default value ) )

5 answers to this question

Recommended Posts

  • 0
Posted

You should be using

$api->post('clients', 'create', $vars);

But aside from that, the 'Failed to retrieve the default value' error is the result of a bug in ionCube. I've never seen it happen in a non-encoding file, though. So it must be calling something in AppModel which is encoded. I hate ionCube so much.

  • 0
Posted
  On 9/29/2015 at 10:29 PM, Cody said:

You should be using

$api->post('clients', 'create', $vars);

But aside from that, the 'Failed to retrieve the default value' error is the result of a bug in ionCube. I've never seen it happen in a non-encoding file, though. So it must be calling something in AppModel which is encoded. I hate ionCube so much.

 

thank you ,but use post method still return same error.

 

I found this can be success in order plugin,signup :$this->clients->create($vars);

 

There are other ways to achieve registration by API, unless post data to a custom plugin then register?

  • 0
Posted
  On 9/29/2015 at 10:29 PM, Cody said:

You should be using

$api->post('clients', 'create', $vars);

But aside from that, the 'Failed to retrieve the default value' error is the result of a bug in ionCube. I've never seen it happen in a non-encoding file, though. So it must be calling something in AppModel which is encoded. I hate ionCube so much.

 

 

CORE-1232  http://dev.blesta.com/browse/CORE-1232

  • 0
Posted

Necro thread sorry.

Had this same issue and found this thread so will post the fix here which I found by following the CORE-1232.

As stated in CORE-1232 "Important to note that this issue does not happen if you specify all parameters to a method".  The fix simply to make sure you pass all parameters, for example.
Does not work:
$response = $api->post("encryption", "systemEncrypt", array('value' => "my text"));
Does work:
$response = $api->post("encryption", "systemEncrypt", array('value' => "my text", 'key' => "f059...[snip]...895f", 'iv' => "f059b0f...[snip]...80fa3895f"));

For this example, you get your encryption key used in the second two prams from config/blesta.php and put it in which is what it should default to anyway.

I suggest an update to the API documentation to cover that in some instances you have to pass all parameters.  On the below API doc, the first two examples should be updated as they don't currently work as they are (or don't for me):
https://docs.blesta.com/display/dev/API

Thanks.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...