Jump to content

Recommended Posts

Posted

So, im using the SDK api from github.

 

 

$response = $api->get("users", "get", array('user_id' => 1));

This returns the details for user number 1.

 

Great!

 

$response = $api->get("clientgroups", "getList", array(1));

This returns:

 

object(BlestaResponse)#2 (2) { ["raw":"BlestaResponse":private]=> string(52) "{"message":"The requested resource does not exist."}" ["response_code":"BlestaResponse":private]=> int(404) }

 

Only ever seems to be when the class name has multiple words in it. i have tried clientgroups, client_groups, client-groups, ClientGroups, Client-Groups etc. I'm lost. 

 

Any ideas?

 

Martin

 

p.s. Blesta Rocks!, but the api is confusing me haha.

 

 

Posted
  On 9/15/2013 at 9:10 PM, Martwana said:

So, im using the SDK api from github.

 

 

$response = $api->get("users", "get", array('user_id' => 1));

This returns the details for user number 1.

 

Great!

 

$response = $api->get("clientgroups", "getList", array(1));

This returns:

 

object(BlestaResponse)#2 (2) { ["raw":"BlestaResponse":private]=> string(52) "{"message":"The requested resource does not exist."}" ["response_code":"BlestaResponse":private]=> int(404) }

 

Only ever seems to be when the class name has multiple words in it. i have tried clientgroups, client_groups, client-groups, ClientGroups, Client-Groups etc. I'm lost. 

 

Any ideas?

 

Martin

 

p.s. Blesta Rocks!, but the api is confusing me haha.

 

Try something like this:

$response = $api->get("ClientGroups", "getList", array($company_id = 1, $page = 1, $order_by = array('name'=>"ASC")));

or

$response = $api->get("client_groups", "getList", array($company_id = 1, $page = 1, $order_by = array('name'=>"ASC")));

 

I'm just guessing here, I haven't tested this.

Posted
  On 9/15/2013 at 11:17 PM, Martwana said:

Need some higher up help, someone more familiar with the code. Alex and myself have been unsuccessful so far

Yeah, I spent quite a while working with Martwana on this. We've traced the request down the stack of the GitHub open source API such that I believe the issue is not there. The $url variable remains unmodified there, but I think the cURLed *.json request isn't being parsed properly on the receiving end when using multi-word models. I have no prior Blesta API experience so bare with me on that. Apache isn't returning a 404, the Blesta codebase itself is erroring out that the resource doesn't exist. We believe somewhere in the Blesta codebase it isn't properly handling multi-word model names from API requests, though. We tried to track it down but our lack of familiarity with the entire codebase made it feel a bit like chasing a needle in a haystack. We're not sure where the request is routed to or how it's handled once it is cURLed off as a *.json request. Regardless, I'm pretty confident that Martwana and I would have found the issue if it was in our actual implementation. Something is awry.

Posted
  On 9/15/2013 at 9:10 PM, Martwana said:
$response = $api->get("clientgroups", "getList", array(1));

 

Two issues here:

  1. First parameter should separate words using underscore, i.e. "client_groups"
  2. Third parameter should be a valid set of key/value pairs for the specific action you're calling from the ClientGroups API

e.g.

$response = $api->get("client_groups", "getList", array('company_id' => 1));
Posted
  On 9/16/2013 at 5:55 PM, Tyson said:

 

Two issues here:

  • First parameter should separate words using underscore, i.e. "client_groups"
  • Third parameter should be a valid set of key/value pairs for the specific action you're calling from the ClientGroups API
e.g.
$response = $api->get("client_groups", "getList", array('company_id' => 1));

Ah, that makes sense, but the documentation may be incorrect:

getList( integer $company_id, integer $page = 1, array $order_by = array('name'=>"ASC") )

may should read

getList( array ( 'company_id' => integer 1, 'page' => integer  1, 'order_by' => array ( 'name' => "ASC" ) ) )

or similar.

 

The docs appear to show the passing of 3 separate vars to this method, not passing a single array with 3 values.

 

A "bad parameters" error would have been helpful in that case, too.

 

Mart is gonna laugh. :lol:

Posted

Many thanks. I never thought about the parameters I was passing to it could return a not found error. 

 

Thanks for clearing that up for me!

 

Many thanks again!

 

Martin

Posted
  On 9/16/2013 at 8:11 PM, Alex said:

Ah, that makes sense, but the documentation may be incorrect:

getList( integer $company_id, integer $page = 1, array $order_by = array('name'=>"ASC") )

may should read

getList( array ( 'company_id' => integer 1, 'page' => integer  1, 'order_by' => array ( 'name' => "ASC" ) ) )

or similar.

 

The docs appear to show the passing of 3 separate vars to this method, not passing a single array with 3 values.

 

A "bad parameters" error would have been helpful in that case, too.

 

Mart is gonna laugh. :lol:

 

The documention is correct, as my link was to the source documentation, not the API SDK documentation which requires the use of key/value pairs in order to explicitly map them to the appropriate method call parameters.

Posted
  On 9/16/2013 at 8:47 PM, Tyson said:

The documention is correct, as my link was to the source documentation, not the API SDK documentation which requires the use of key/value pairs in order to explicitly map them to the appropriate method call parameters.

 

Ah! Thanks for clearing that up. Sorry if I am asking dumb questions, I'm admittedly trying to help prior to using the API myself.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...