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

404 error when using browser url

$
0
0

by Elliott Lovell.  

I am attempting to view the json response in a browser for the custom service that I created on my moodlecloud site.


I have four functions, and I am trying to return the calendar events.



The url is formatted as follows:

https://mysite.moodlecloud.com/moodle/webservice/rest/server.php?wstoken=XXXXXXXXXXXX&wsfunction=core_calendar_get_calendar_events&moodlewsrestformat=json

The token I am using is specific to my _admin user. Do I need to append anything else to the end of the url? As is, this URL takes me to the Moodle 404 page.


Re: 404 error when using browser url

$
0
0

by Elliott Lovell.  

Update:  I removed /moodle from the URL and was able to get an invalid token json response back in the browser. I was using the example URL from the Creating a web service client page, so I suppose that doesn't apply for a moodlecloud site.

Why $_POST is empty when send postfields ?

$
0
0

by Jesus Marquez.  

I am using curl_php:

curl_setopt($curl, CURLOPT_POST, 1)
        curl_setopt($curl, CURLOPT_POSTFIELDS, $str)
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true)
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-type: application/x-www-form-urlencoded'))

$str variable is code to style URL http_build_query() is a users array

However, send $str in URL 

$curl=curl_init($serverurl . $restformat . '&' . $str)
curl_setopt($curl, CURLOPT_POST, 1)
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true)
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-type: application/x-www-form-urlencoded'))


Then $_POST has pairs values but bad encode:

screen


Any help...thanks!

web service core_files_upload, The file has not been specified

$
0
0

by Carlos H Bolaños.  

Moodle version 3.3


Best regard,


I have configured the REST web service.


he made tests with core_course_get_courses and everything perfect, if you list me. BUT when I use core_files_upload with its required arguments (context, component, file area, itemid, file path, file name, file content, context level, instanceid)


He throws me the following, but does not look for solutions or examples.


"exception": "moodle_exception",


"errorcode": "nofile",


"message": "The file has not been specified"



Re: core_course_create_courses does not accept French accents characters

$
0
0

by Karen Holland.  

Hi Ahmed, I'd recommend that if you can re-create the issue on the latest version of Moodle, that you should check tracker for any related bug reports and if not there, that you should create a bug report yourself.

Calling core_enrol_get_enrolled_users - Invalid parameter error

$
0
0

by Azmat Ullah.  

Hi,

I'm trying to get enrolled users of the course but getting invalid parameter error. While passing correct parameter.


$functionname = 'core_enrol_get_enrolled_users';

$params = array('courseid' => 64, 'options' => array());

$serverurl = $domainname . '/webservice/soap/server.php'. '?wsdl=1&wstoken=' . $token;

$client = new SoapClient($serverurl);

try {

$resp = $client->__soapCall($functionname, array($params));

} catch (Exception $e) {

    print_r($e);

}

if (isset($resp)) {

    print_r($resp);

}

Get Updated Grades Since the given time stamp

$
0
0

by Mohammad Hadiuzzaman.  

Hi there,

I need assistance on API functionality for getting the grades that updated since a given time.  The core function  core_grades_get_grades only allow to get specific Course grades using courseid parameter.

As like the function core_course_get_updates_since we can get updated courses since a time. Like this, is there any function by using it we can get the grades that updated since a given time? Or please assist me that how to achieve this.

//regards,
Hadi

error in display "mod_quiz_get_attempt_data" result

$
0
0

by Masoud Vafaei.  

Hi All

I'm trying to develop an external client for quiz module. 

and use mod_quiz_get_attempt_data to fetch quiz question. when I want to show the result in HTML view, faced with the attached error.


Uncaught ReferenceError: M is not defined

Uncaught ReferenceError: Y is not defined


can anyone help me?

thanks a lot


Re: REST API: check if user exists?

$
0
0

by Rosa Muñoz.  

Hello
I'm trying to create a web service to authenticate users, given that, it has a custom function that I program.

What I do not understand is how to consume this function. I have been following this tutorial https://docs.moodle.org/34/en/Using_web_servics

At the moment of selecting the function none of the existing functions is useful, given that I can not add any function and the function that I programmed does not appear. What I can do?


Re: error in display "mod_quiz_get_attempt_data" result

$
0
0

by Shamim Rezaie.  

Hi Masoud,

Please post the full response you receive after calling mod_quiz_get_attempt_data.

Re: error in display "mod_quiz_get_attempt_data" result

$
0
0

by Masoud Vafaei.  

Hi 

result file has been attached. 

Re: REST Web service - Missing required key in single structure: groups

$
0
0

by Mohammad Gholipour.  

Hi alexis

did you fix reported error?

I have such a problem to test create_category service.

I did it at https://demo.moodle.net  and it was successful, but in my site following error was occurred.

If you have founded the solution please help me?

error



Re: error in display "mod_quiz_get_attempt_data" result

$
0
0

by Shamim Rezaie.  

The html bit that mod_quiz_get_attempt_data returns is just the bit that is for the questions of the quiz. It's not a complete html document. You need to add <html></html>, <head></head> and <body></body> pairs to that to build a complete html document.

Here is what you can do. Using your browser, go the quiz page and then view the page source (html code). Using the generated html you see there, create an html document like below:

<html>
<head>
<!-- the hole content of the head section -->
</head>
<body>
<!-- load yui-moodlesimple.js and javascript-static.js scripts -->
<!-- the html bit you get from mod_quiz_get_attempt_data -->
</body>
</html>

Re: error in display "mod_quiz_get_attempt_data" result

$
0
0

by Masoud Vafaei.  

thanks for your reply. 


But on the normal quiz page, the generated code similar to the attachment is also generated. The main question is: how can we generate that js code and use in our app?


اما در صفحه معمولی آزمون علاوه بر دو فایلی که شما فرمودید، کد تولید شده ای (generated code ) مشابه فایل پیوست نیز تولید می شود. سوال اصلی این است با چه مکانیزمی می شود این کد را تولید کرد. 

این کد حاصل خروجی تابعی به نام get_head_code است. ,ولی نحوه استفاده از ان در وب سرویس رو نمی دونم. 

با تشکر 

Grade point update using core_grades_update_grades function?

$
0
0

by prasad pulipati.  

How to update the grade points of the particular student? Can any one provide the url for curl test?

I tried this one

http://localhost/webservice/rest/server.php?wstoken=668e1da48055ba6e02f8f12&wsfunction=core_grades_update_grades&courseid=2&component=Col2&itemnumber=4&userid=1&finalgrade=100.0&feedback=well

I am getting following error

{"exception":"invalid_parameter_exception","errorcode":"invalidparameter","message":"Invalid parameter value detected","debuginfo":"Missing required key in single structure: source"}


Grade Item creation api/webservice?

$
0
0

by prasad pulipati.  

Hi all,

I want to create grade item through code is there any api or webservice i can use?

Can anyone please suggest.

Web Services and Events 2 Integrations

$
0
0

by lucio beirao.  

Hello all, 


I was just searching on how to work with the Moodle Web Services API and use them together with the Events 2 API, but no much luck until now. I can, for example, create users and delete them with Web Service functions, but I need to know if there's a way to handle events by a web service, or send data from Moodle to my application when an event is triggered, or know if an event was triggered trough the Web Services. The last part, I would say that seems not being so possible, but I haven't found other alternatives on how to handle this in my software.


I don't know enough about Moodle, so i cannot say whether or not it has such functionality, but at least some links provided from the documentation on how to do things of this kind, would be great. I already read a big part of the Events 2 docs and Web Services as well, but could not find a way to integrate these things.


If someone could help me with this, it would be great.


Thanks in advance.

Moodle version update and web services not working

$
0
0

by Ish Kaur.  

I updated the moodle version from 2.9.2 to 3.3.3. I am geeting the following error while running the web services.

<?xml version="1.0" encoding="UTF-8"?>

-<EXCEPTION class="invalid_response_exception">

<ERRORCODE>invalidresponse</ERRORCODE>

<MESSAGE>Invalid response value detected</MESSAGE>

<DEBUGINFO>users => Invalid response value detected: username => Invalid response value detected: Invalid external api response: the value is "ADMIN_CGUINDON", the server was expecting "username" type</DEBUGINFO>

</EXCEPTION>

 

Any Idea?


"Invalid Parameter Value Detected" in local_o365_update_onenoteassignment

$
0
0

by Berk Eren KOCA.  

Hi, I'm trying to delvelop a system which consumes some of the Moodle's web services. In this system there are 3 steps related with the Moodle's web service which are:

-Get all the courses belong to Instructor
-Get all the assignments belong to selected course
-After editing the assignment, update it with the latest one.

I easily implemented first two of them but updating an assignment is the problematic part. When I use local_o365_update_onenoteassignment function, it returns "Invalid Parameter Value Detected" error although parameters are correct. Here is my code below. I appreciate it if you help me.

       
        String token = "adcd621f420dfc3000f106a6ebcebccb";
        String domainName = "http://localhost:81/moodle";
        String functionName = "local_o365_update_onenoteassignment";
       
        String urlParameters =  "data[coursemodule]= "+CurrentAssignment.getCourseModuleID()+
                                "&data[course]="+Course.getCurrentCourse().getCourseId()+
                                "&data[name]="+CurrentAssignment.getAssignmentName()+
                                "&data[intro]="+CurrentAssignment.getIntro()+
                                "&data[section]= 0"+
                                "&data[visible]= 1";
                                
        String restformat = "&moodlewsrestformat=json"; 

        String serverurl = domainName + "/webservice/rest/server.php" + "?wstoken=" + token + "&wsfunction=" + functionName;
        HttpURLConnection con = (HttpURLConnection) new URL(serverurl).openConnection();
        con.setRequestMethod("POST");
        con.setRequestProperty("Content-Type",
        "application/x-www-form-urlencoded");
        con.setRequestProperty("Content-Language", "en-US");
        con.setDoOutput(true);
        con.setUseCaches (false);
        con.setDoInput(true);
        DataOutputStream wr = new DataOutputStream (
        con.getOutputStream ());
        wr.writeBytes (urlParameters);

        wr.flush ();
        wr.close ();

Can't run REST core_course_get_courses due to memory

$
0
0

by Matthew Davidson.  

We have ~8000 mdl_course rows and when we attempt to run a REST API call for core-course_get_courses, it errors out with a 500 because it is exhausting our ram.  We have tested up to 16gb of ram allocated to PHP.  This seems like an insane amount of memory to deliver a table that is only 6MB on the disc.


Any idea what could be happening?

Viewing all 2363 articles
Browse latest View live


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