Quantcast
Channel: Web services
Viewing all 2361 articles
Browse latest View live

Re: Fetch assignment details for a course, including due dates.


Re: Unable to set 'department' and 'institution'

$
0
0
by Richard van Iwaarden.  

This has been fixed and will probably be in Moodle 3.6

Student unable to list their own courses!

$
0
0
by Petar Nikolovski.  

Hi, I've set a "student" role for a user, and enrolled them in the course. The user is able to successfully obtain token, however when trying to fetch courses using "core_enrol_get_users_courses" the following exception is raised:


{'exception': 'webservice_access_exception', 'errorcode': 'accessexception', 'message': 'Access control exception'}


I've looked into source code (https://github.com/moodle/moodle/blob/MOODLE_34_STABLE/lib/db/services.php#L548-L555), and the privilege that is required for this role is already selected in my role. Why is student still unable to fetch the list of courses they are enrolled in? Do I have to change Student role to be system wide?

Unable to manual enrol: enrol_manual_enrol_users

$
0
0
by Hajo Emch.  

Hi

I tried to enrul a user with c# and get the message: Missing required key in single structure: userid

I do it the same way as creating courses or users, so I think the format is correct.

Before the enrolement I did a 'core_user_create_users' with withcreatepassword and I activated the user.

There is another topic: https://moodle.org/mod/forum/discuss.php?d=341946

Can it be a problem with permissons?

Thanks for Help

Hajo

Re: core_user_get_users_by_field return blank array

$
0
0
by Tim Titchmarsh.  

Hi


Did you get this to work?


I'm having similar issue, I can get user data by id but not by email, username etc. I think its because email and username (and many others) are optional fields and return blank when  I fetch using core_user_get_users_by_field and passing the id field  via the webservice.

Anyone know how to enable these optional fields and return data instead of empty fields?

Thanks

Tim

Re: Web Service User Cannot Change Another User's Preferences

$
0
0
by Matt Sawatzky.  

Did you ever figure out the issue?

I am having the same problem.

Re: Myddleware and Magento

Re: Unable to manual enrol: enrol_manual_enrol_users

$
0
0
by Tim Titchmarsh.  

Hi

Unlikely to be permissions with that error message I would think, more likely the names of the parameters. I use:


        write_log("add user to course " .  $moodle_user_id . "" .  $course);

        $moodlcourse = new stdClass();

        $moodlcourse->roleid = 5; // student

        $moodlcourse->userid = $moodle_user_id;

        $moodlcourse->courseid = $course;

        array_push($moodlecourses,$moodlcourse);

        $params = array("enrolments" => $moodlecourses);

        //write_log(var_dump_ret($params));

        MoodleIt("enrol_manual_enrol_users", $params);

What do you have ?

Tim


core_enrol_edit_user_enrolment

$
0
0
by Tim Titchmarsh.  

Hi


Has anyone tried the new core_enrol_edit_user_enrolment web services call?

I have managed to setup users, enrol users in courses via web services and all works fine.

I wanted to suspend a user from a course and see that you can now update the status of the enrolment (active, suspend) via core_enrol_edit_user_enrolment. 

The docs (from my site api docs page) are a little off and ambiguous for this call but when you dig down and see what the UI is doing and reverse engineer it you can see what id's its using I can manually set my parameters to the call and see the results. The problem is ueid appears to be the user enrolment id and I cant see a call I can make that returns that value. I can find out what courses a user is in but cant get hold of the euid. I can get the user id, the course id but not the user enrolment id which I guess is join between users and their enrolments.


Any ideas

Thanks

Tim

How to get all users with core_user_get_users and PHP

$
0
0
by Josip Zmikic.  

Hi there,

i have been going round and round witht his problem. I can get specific user if i use their id or email, but i cant get more then one user via api call.

The user i get isnt limited to just admin or loged in user so permisions should be ok.

The web service documentation states that i can use % in my search so my general idea was to send request for email with % criteria and that would return me list of all users that have email.

After that failed i tryed using auth field as a filter but that one never returned anything to me.

Can someone give me a working example for my issue. The curl url i use for this is :

$url.'webservice/rest/server.php'. '?wstoken=' . $token . '&wsfunction=core_user_get_users&moodlewsrestformat=json&criteria[0][key]=email&criteria[0][value]=%';

This is just one variation of what i tryed but usuallythe resulti get is either an empty json or just empty result with nothing in it.

Thank you in advance.

Kind regards,

Josip

Web service Error ('args' parameter)

$
0
0
by Blanca Pena.  

Hello Moodle Community!

We have set up a web service to connect to an external system. The external system is called KuferSQL. We want to transfer all courses from KuferSQL to the Moodle Platform (version 3.4+). We have followed all steps to the activation of the web service just as explained in the Moodle documentation.  Our problem: By trying to connect to the external system to transfer a course to Moodle, we get an error message:

"The web service description parameter named 'args' is an single or multiple structure. It can not be set as VALUE_OPTIONAL. Check web service description."

Can someone help us? What does this message mean? What and where exactly should we something add or change? Who should solve this problem? The Moodle host, the KuferSQL operator, or the Moodle administrator? We (administrators) do not have direct access to the Moodle database only to the Moodle directory. We have been trying to solve this problem but we get not any further. We will be very grateful if someone could help us.

Thanks alot.

Estela

Moodle Web Services Development

$
0
0
by Mohamad El Bohsaly.  

Dears,

As a web developer with a few months of experience (HTML/CSS/JavaScript/PHP), what track is preferable to follow regarding Moodle's Web services?

Re: Unable to manual enrol: enrol_manual_enrol_users

$
0
0
by Hajo Emch.  

Hi Tim

thanks for help. 

I use data transfer objects with xml Attributes and had a space after userid. 

Now it works better, but I get: 

 {"exception":"require_login_exception","errorcode":"requireloginerror","message":"Kurs oder Aktivit\u00e4t nicht benutzbar","debuginfo":"Not enrolled"}


I use a call with  https://<my-site>/webservice/rest/server.php?wstoken=<mytoken>&wsfunction=enrol_manual_enrol_users&moodlewsrestformat=json&application/x-www-form-urlencoded=enrolments…

This works for me for example for the method core_course_update_courses 


Do I also have  to submit username and Password?


Hajo 


Re: Web service Error ('args' parameter)

$
0
0
by Kevin Frye.  

I have a similar issue related to setting up web services. I am using Iomad and have tested this originally in version 3.2 and it worked well. I am deploying a site and started fresh with Iomad 3.4, then tried 3.3 and have reverted to 3.2. I get a similar problem in all versions when attempting to create functions for my web service.

The error I see is:

Exception - Argument 1 passed to external_multiple_structure::__construct() must be an instance of external_description, array given, called in [dirroot]/blocks/iomad_company_admin/externallib.php on line 315


Have you managed to solve your issue?

Re: Unable to manual enrol: enrol_manual_enrol_users

$
0
0
by Hajo Emch.  

If I enrol my service user to the course and give him the permission 'Allow role assignments' then it works. 

But I dont want to enrol my service user! Is there a way to enrol students, without enroling the service user?

Thanks for help


Addning Course enrolment method through webservices.

$
0
0
by santosh Suwarnkar.  

Hi,

I have installed "Webservice functions for cohort enrolment" plug in to Add a cohort enrolment instance to a course.

I have implemented code for  "local_ws_enrolcohort_add_instance" function but for some cohorts its working and for some cohorts its showing below errors
Array
(
[faultCode] => 10648825
[faultString] => Object is not available at this context! | DEBUG INFO: Cohort with id 39 is not available at this context. | ERRORCODE: unavailableatcontext
)

Can any one please explain where is my mistake?


My Code -
/// SETUP - NEED TO BE CHANGED
$token = '41d74182154a8b8197d41730373faf16';
$domainname = 'http://redchipmoodle.in/noodlenow/';
$functionname = 'local_ws_enrolcohort_add_instance';

$params = new stdClass();
$params->courseid  = 6;
$params->cohortid = 42;
$params->roleid = 5;
/// XML-RPC CALL
$serverurl = $domainname . '/webservice/xmlrpc/server.php'. '?wstoken=' . $token;
require_once('curl.php');
$curl = new curl;
$curl->setHeader('Content-type: text/xml');
$post = xmlrpc_encode_request($functionname, array($params));
$resp = xmlrpc_decode($curl->post($serverurl, $post));
echo "<pre>";
print_r($resp);

Web service running in Docker connecting to Moodle running in Docker

$
0
0
by Ning H.  

Hi, 

I have an LTI app that's running in Docker on my local machine, and I want to call Moodle web services with it. Moodle is also running on Docker on my local machine.

The client I am using is https://github.com/mudrd8mz/node-moodle-client.

Currently, the Moodle and app containers are in the same Docker network, so I can only call the Moodle web server with the IP address it's given in Docker (172.19.0.x). When the Moodle web server receives the GET request, it tries to redirect the app to http://localhost:8000 which returns a connection refused error to the app. 

What I've tried:

  • Changing Moodle's wwwroot to http://172.19.0.x
  • Putting the Moodle web server in the Docker host network
  • Adding the Moodle web server 172.19.0.x to /etc/hosts in the Moodle web server container and my personal computer as localhost
  • Adding "localhost" as an alias for the Moodle web server container

What can I do to call web services from the app while also using Docker?

Thank you.

Re: Web service running in Docker connecting to Moodle running in Docker

$
0
0
by Matteo Scaramuccia.  

Hi Ning,
what is the Moodle image your container is running from?

From the error (localhost:8000), I'm guessing you're using https://github.com/moodlehq/moodle-docker/ .

If confirmed, you can configure both host and port via MOODLE_DOCKER_WEB_HOST and MOODLE_DOCKER_WEB_PORT, respectively.
Just configure them using the IP of the host and the port exposed to the host i.e. what expected by your client.

HTH,
Matteo

Re: Web service running in Docker connecting to Moodle running in Docker

$
0
0
by Ning H.  

Hi Matteo, 


Thank you for the suggestion! 

I was able to fix the issue earlier today on the app side by putting the app server inside the host network.



Re: Web service running in Docker connecting to Moodle running in Docker

$
0
0
by Matteo Scaramuccia.  

Great approve!
Yes, under the same network it is reachable even via the named service, if you'll play with a docker composition.

Enjoy!
Matteo

Viewing all 2361 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>