Forums | Mahara Community

Developers /
web service client


Osbel Rondón's profile picture
Posts: 23

26 March 2017, 10:09 AM

Hello everyone
I am trying to consume a mahara web service from an external page but it throws me a postgres syntax error. Does anyone know where the problem may be? I have tested the service on the test client that has Mahara and works perfectly

This is the code I have written

-------------------------------------------------------------------------------------------------------------

Zend_Loader_Autoloader::autoload('Zend_Loader');
 
 $serverurl = 'https://localhost/mahara_otro/htdocs/webservice/rest/server.php';
 $token = '71a446ccf819b2208e66d447fd5ddd42';
 
 $params = array(
     'wsfunction' => 'mahara_user_get_online_users',   // the function to be called
     'wstoken' => $token, //token need to be passed in the url
 );
 
 $client = new Zend_Http_Client($serverurl);
 try {
     //$client->setParameterPost($params);
     $response = $client->request('POST');
     var_dump ($response->getBody());
 } catch (exception $exception) {
     var_dump ($exception);
 }

------------------------------------------------------------------------------------------------------------

And this is the result:

------------------------------------------------------------------------------------------------------------

string '<?xml version="1.0" encoding="UTF-8" ?>
<EXCEPTION class="SQLException">
<ERRORCODE>0</ERRORCODE>
<MESSAGE>Failed to get a recordset: postgres8 error: [-1: ERROR:  error de sintaxis en o cerca de «LIMIT»
LINE 1: SELECT * FROM &quot;external_tokens&quot;  WHERE &quot;token&quot; = ?  LIMIT 2
                                                            ^] in EXECUTE(&quot;SELECT * FROM &quot;external_tokens&quot;  WHERE &quot;token&quot; = ?  LIMIT 2&quot;)
Command was: SELECT * FROM &quot;external_tokens&qu'... (length=569)

------------------------------------------------------------------------------------------------------------

Thanks in advance

Robert Lyon's profile picture
Posts: 360

27 March 2017, 10:21 AM

Hi Osbel

I can replicate the error you are getting. We need to add a check to see if the token is supplied before trying to check that it is unique.

I've created a patch to deal with this: https://reviews.mahara.org/#/c/7565/

Where we check existence of $token and return normal error if missing

Please let me know if that fixes your problem

Cheers

Robert

Osbel Rondón's profile picture
Posts: 23

27 March 2017, 2:28 PM

Hello, Robert

I already added your patch and the error is precisely that the token is invalid or not supplied

Now I get the normal error message. "<MESSAGE>Access control exception : Invalid token selected or none supplied</MESSAGE>"

How can I know now if the token is invalid or not supplied?

I keep abreast

Osbel

3 results