General developer forum

What i must use? Moodle API web services or quering directally to database?

 
Picture of Alejandro Molina
What i must use? Moodle API web services or quering directally to database?
 

What i must use? Moodle API web services or quering directally to database


pros and cons


Thanks for you response.

 
Average of ratings: -
Picture of Mark Johnson
Re: What i must use? Moodle API web services or quering directally to database?
Core developersParticularly helpful MoodlersPlugin developers

Hi Alejandro,

I'm afraid you've not really given us enough detail to answer your question.  What is the result that you're hoping to achieve?

 
Average of ratings: -
Picture of Alejandro Molina
Re: What i must use? Moodle API web services or quering directally to database?
 

Thanks for your response.


Im making an app that uses moodle, not as a plugin, but as a stand-alone app. I want to read some data (courses, activities, etc.) from moodle, but i have problems using the web service.


For example

The teachers have the capabilities for generate token and call the function core_course_get_courses. I can generate a token but when i tried to call the web service it returns webservice_access_exception. I checked the teacher capabilites and the teachers has the core_course_get_courses capabilities. 


I prefer to use the web service because i want to use the moodle role to access to resource, but this problems limits me. 


 
Average of ratings: -
Picture of Mark Johnson
Re: What i must use? Moodle API web services or quering directally to database?
Core developersParticularly helpful MoodlersPlugin developers

Hi Alejandro,

Using web services is the correct approach for this.  In fact, this is exactly how the official Moodle app works. If you haven't already it's worth taking a look and seeing if that suits your needs.

It looks like webservice_access_exception is thrown in lots of different cases.  If you can include the error message it returns, it might help someone identify your problem.

 
Average of ratings: -