Jump to content
  • 0

How To Debug An Api Call


a.daniello

Question

I'm trying to add an user from another service, calling the API users->add, like follow:

$api = new BlestaApi($url_api, $user, $key);$_add = $api->get("users", "add", array(
                'username' => $email,
                'new_password' => $_pwd,
                'confirm_password' => $_pwd,
                'two_factor_mode' => 'none',
                'two_factor_key' => '',
                'two_factor_pin' => ''
            ));

I get always this response:

{"message":"An unexpected error occured.","response":"Internal error"}500

No errors are reported in web server logs, and i don't know how to debug this error. In documentation (http://docs.blesta.com/display/dev/API) i read:

 

All error response objects contain an array of input parameters that produced errors. From the example above "field" is the parameter name. Each field may contain one or more error codes along with a related message. Common codes are empty,existsformatlength, and valid, but many more are available. The error code is always the index of the error message, and is used primarily in identifying the type of error encountered.

 

 

But i don't get other info.

 

Anyone can help me? How i can find more info to debug an error in Blesta?

 

Many thanks,

Achille

Link to comment
Share on other sites

6 answers to this question

Recommended Posts

  • 0

Found problem!

 

I' missing 'vars' in call:

$api = new BlestaApi($url_api, $user, $key);$_add = $api->get("users", "add", array('vars' => array(
                'username' => $email,
                'new_password' => $_pwd,
                'confirm_password' => $_pwd,
                'two_factor_mode' => 'none',
                'two_factor_key' => '',
                'two_factor_pin' => ''
            )));

Thanks,

Achille

Link to comment
Share on other sites

  • 0

I made the same mistake.  If you try to import services there's also a very misleading part of the docs that caused me to use the wrong ID for one of the calls.

 

What part is misleading from the docs?

 

 

Found problem!

 

I' missing 'vars' in call:

$api = new BlestaApi($url_api, $user, $key);$_add = $api->get("users", "add", array('vars' => array(
                'username' => $email,
                'new_password' => $_pwd,
                'confirm_password' => $_pwd,
                'two_factor_mode' => 'none',
                'two_factor_key' => '',
                'two_factor_pin' => ''
            )));

Thanks,

Achille

 

Glad you were able to figure it out. You should be using POST rather than GET for that request, though.

 

But as you're probably aware of now, the third parameter to each of the API SDK methods (get/post/put/delete) is $args: an array containing each of the methods' arguments, as described in the docs.

Link to comment
Share on other sites

  • 0

What part is misleading from the docs?

 

http://source-docs.blesta.com/class-Services.html#_add

 

"pricing_id The package pricing schedule ID for this service" refers to the "id" column in the package_pricing table.

 

Since there's also a "pricing_id" column in the package_pricing table this is what I thought it was referring to.  Spent about 2 hours banging my head against the wall before figuring this out...

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...