Jump to content
  • 0

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


ty0716

Question

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 ) )
Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0

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.

Link to comment
Share on other sites

  • 0

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?

Link to comment
Share on other sites

  • 0

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

Link to comment
Share on other sites

  • 0

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...