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

Re: Re: Rest API for authentication


Re: Aw: Re: Re: Rest API for authentication

$
0
0
by Fehmi M'Barek.  

Hi Stefano,

you have to be sure that the Service is enabled. Go to:

Site administration > Plugins Web services > External services > External service

Enable external Services moodle

Which Version of moodle are you running?

Best regards
Fehmi

Re: Re: Aw: Re: Re: Rest API for authentication

$
0
0
by Stefano Fiscale.  

I am not using the built-in Moodle mobile web service, here is my situation:

I developed my custom mobile application. In my moodle site I created my custom service with some web services and I set the whole environment (for example role and permissions for the web services execution) and everything works correctly.

Now I'm looking for a Moodle web service for the login. I didn't find anything in the API documentation.

What should I do?

Thanks,

Stefano

Re: Aw: Re: Re: Aw: Re: Re: Rest API for authentication

$
0
0
by Fehmi M'Barek.  

Ahhhh now I understand,

you don't need to authenticate. Because this is an authorization request. You need to create an authorization Token for that particular user that you have created.

You have to go to "> Site administration > Plugins Web services > Manage tokens"

After that you fire out a request without authentication. Thats how so called OAuth2 authorization Tokens work.

curl -X POST \
'https://mymoodle.tld/webservice/rest/server.php?wstoken=XXXXXXXXXXXX&wsfunction=core_course_create_courses&moodlewsrestformat=json&courses[0][fullname]=MyCourse&courses[0][shortname]=ShortName&courses[0][categoryid]=14&courses[0][format]=&courses[0][visible]=&courses[0][groupmode]='

Hope that helps you.

Best regards
Fehmi

Re: Post payload didn't send to Web Service via RAW/JSON

Re: Re: core_user_get_users_by_field return blank array

Problem with creating user via REST Api

$
0
0
by Nikolai Dimitrov.  

Hello,

I am trying to create new user using  this(https://github.com/bantonia/MoodleRest) code. Ive created user and i am trying to call __createUsers

from MoodleRestUser and i am getting:

"[Fatal Error] :2:10: Already seen doctype.

Jun 07, 2019 11:54:26 PM net.beaconhillcott.moodlerest.MoodleCallRestWebService __call

SEVERE: null

org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 10; Already seen doctype.

at java.xml/com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:261)

at java.xml/com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:339)

at java.xml/com.sun.org.apache.xpath.internal.jaxp.XPathImplUtil.getDocument(XPathImplUtil.java:129)

at java.xml/com.sun.org.apache.xpath.internal.jaxp.XPathImpl.evaluate(XPathImpl.java:180)

at net.beaconhillcott.moodlerest.MoodleCallRestWebService.__call(MoodleCallRestWebService.java:386)

at net.beaconhillcott.moodlerest.MoodleRestUser.__createUsers(MoodleRestUser.java:165)

at net.beaconhillcott.moodlerest.MoodleRestUser.__createUser(MoodleRestUser.java:55)

at Test.main(Test.java:52)

--------------- linked to ------------------

javax.xml.xpath.XPathExpressionException: org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 10; Already seen doctype.

at java.xml/com.sun.org.apache.xpath.internal.jaxp.XPathImplUtil.getDocument(XPathImplUtil.java:131)

at java.xml/com.sun.org.apache.xpath.internal.jaxp.XPathImpl.evaluate(XPathImpl.java:180)

at net.beaconhillcott.moodlerest.MoodleCallRestWebService.__call(MoodleCallRestWebService.java:386)

at net.beaconhillcott.moodlerest.MoodleRestUser.__createUsers(MoodleRestUser.java:165)

at net.beaconhillcott.moodlerest.MoodleRestUser.__createUser(MoodleRestUser.java:55)

at Test.main(Test.java:52)

Caused by: org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 10; Already seen doctype.

at java.xml/com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:261)

at java.xml/com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:339)

at java.xml/com.sun.org.apache.xpath.internal.jaxp.XPathImplUtil.getDocument(XPathImplUtil.java:129)

... 5 more"

My code is:

   public static void main(String[] args) throws ProtocolException, IOException, MoodleRestUserException, MoodleRestException {

         String token = "93ec5f7001a84j64c7b2563ce1998e31";

        String domainName = "http://localhost/moodle/";

        MoodleUser mu = new MoodleUser("javauser","Password","Testcho","Testov","mailche@mail.com");

        mu.setAuth("manual");

        mu.setIdNumber("test1");

        MoodleRestUser mru = new MoodleRestUser();

        mru.__createUser(domainName, token, mu);    }

        With another example i have created user and i thats why i am sure that my token is valid and moodle can handle that call. Thanks in advance for the help.

Login API

$
0
0
by Stefano Fiscale.  

Hi,

I'm developing a mobile app for my university that uses moodle web services.

I've read API documentation and I didn't find anything about login web services and this is a big problem.

I want that a user, in my app login module, digits his credentials and through a moodle web service I can establish if that credentials are correct or less.

Can anyone help me?

Thanks in advance,

Stefano.


Re: Login API

$
0
0
by Stefano Fiscale.  

For those who have had the same problem, here's the solution:

from terminal execute the following command:
$ curl -c - -i -F'username=myusername' -F'password=mypassword' -F'service=moodle_mobile_app' -X POST http://mymoodlesite/login/token.php

The response will be something like:
{"token":"696ded7cd77a8041c0332423a9e8c78b","privatetoken":null}#

Web Service. Get Competencies in activity.

$
0
0
by Elias Santiago.  

Hello. I can't seem to find a web service API function to get the competencies in an assignment. How can I get the competencies in a quiz or assignment remotely?

Adding a new web service function

$
0
0
by Adam Oudaimah.  

Here at Tishreen University, We are trying to develop a new Web Identity for our university.
And for this purpose, We are using Moodle as the main system for our university LMS.
The problem I'm facing is that the main site is requesting some information from Moodle.
The existing Web Service API functions is not enough to satisfy the requirements.
I want to write a new function, for example I want to get all the sub-categories inside a certain category by sending the ID of the category.
All I need is to add a new function to the Web Service API functions inside Moodle.
Is there any way to do this? I mean to add a new function to the Web Service API functions.
The solution I found is to add a new plugin, but does the function which I wrote inside the plug-in is accessible from a web service?
Is this the right way to do it?
Thanks a lot.
Best Regards

Adding activities to a course with web service

$
0
0
by Andreas Schenkel.  

I was able to create a new course with 

http://***domain***/webservice/rest/server.php?wstoken=********************&wsfunction=core_course_create_courses&moodlewsrestformat=json&courses[0][categoryid]=5&courses[0][fullname]=testcoursename&courses[0][shortname]=testcoursename

Now I want to add activities to the course using web service. Is this possible? Is there already a function that could be called?





Error creating users via the web service

$
0
0
by Xollie Mdlalose.  

Hi,

I am new to moodle and I am struggling to create 100 users via the core user create users api using php

I am able to create 7 or less users but once I push 20 or more i get an error message of which I think its because of the Rest maximum URL lengthsad

How can I solve this, please see my code snippet below

$tokenurl = 'http://myserver/login/token.php?username=admin&password=Admin&service=Students';


$tokenresponse = file_get_contents($tokenurl);


$tokenobject = json_decode($tokenresponse);


if (!empty($tokenobject->error)) {

    echo $tokenobject->error;

    die();

}


$users = array(array($BulkUserImport)); //BulkUserImport is an array containing 100 students 


$params = array(

    'wstoken' => $tokenobject->token,

    'wsfunction' => 'core_user_create_users',

    'moodlewsrestformat' => 'json',

    'users' => $users,

);

Moodle app single sign on hack

$
0
0
by amine brahim.  

Hi...

There is a problem with the sso in moodle app , when Its demand to a user to enter his credentials via the embedded browser, he can press the "return" button in his phone and he will be able to enter the site even if another user is connecting with the same credential in another pc ...!!!

Re: Moodle app single sign on hack

$
0
0
by Juan Leyva.  

Hi Amine,

I'm sorry, I'm not sure if I understand what's the problem here, having two concurrent sessions? Or being able to reuse the old browser session to launch the app?

Re: Moodle core_user_create_users Access control exception

$
0
0
by Bob Belz.  

I had this error "Access control exception". Enabling REST in Moodle administration for the role user is in worked for me

Site administration > Users > Define roles > the role in question, for example Student > Edit > Use REST protocol, webservice/rest:use > check it

There are also SOAP, XML-RPC protocols there to try enabling. 

Also maybe this role needs to get set (on the same page) to

"Context types where this role may be assigned"> System

"Create a web service token for mobile access", moodle/webservice:createmobiletoken -> checked too if this error is on mobile app.

Re: How to retrieve the User Enrolment ID

$
0
0
by Jo Ha.  

Hello,

I'm in a similiar situation as carlos - I want to change a user enrollment (role in course) via webservice.

Happily I found the core_enrol_edit_user_enrolment webservice function which allows that (well, at least i thought that from its name). But apparently that webservice requires some parameters, which you are not able to get via webservice... (But wouldn't that, if true, make the core_enrol_edit_user_enrolment webservice completly superfluous?)
And secondly, the core_enrol_edit_user_enrolment  only allows changing enrolment status and time, correct?!

This leads me to following questions:

  1. Is it possible to use the core_enrol_edit_user_enrolmentwebservice for changing the user enrollment in a course, or to be more precise, the role(s) a user is enrolled in a course.
  2. (If 1) What webservice can be used to retrieve the information needed as parameters for core_enrol_edit_user_enrolment ?


Maybe I'm on the wrong track with the above, so my general question is:

What webservice to use for changeing a users role(s) in a course. I know courseid, userid and new roleid.


Thanks in advance.

Mobile application development services

$
0
0
by Micheal Clarke.  

Rajasri Systems is a leading Mobile application development company in Chennai. We are one of the best app development company in India. We provide innovative and robust custom mobile application development services with our team of app developers to exceed the customer's expectations.

Mobile application development company in Chennai

Our Services:

Xamarin Android App Development

Xamarin Forms App Development

Xamarin Mobile application development

Xamarin For Enterprises

Xamarin Developer Hire Services

Why Choose US:

Our developer has good working experience with the US and Japanese clients.

100% Client Satisfied

App Store Optimization Friendly

Responsive Design

Affordable.

Have a project in mind? Let's talk!!!

Connect with us at: Xamarin mobile application development for android

Get a free quote:

Contact Us on Skype: “rajasrisystems1”

Mail at: businessdev@rajasri.net


Get roles Webservice API

$
0
0
by Venel Romain.  

Hello everyone,

I wanted to know if it was possible to get the roles of a user via the webservice. I haven’t found any endpoints to do that, and the only answers told me to go through the database, but I don’t have access to it.

Is there a way to do that?

Thank you and have a nice day !

Moodle app single sign on hack

$
0
0
by amine brahim.  

Hi...

There is a problem with the sso in moodle app , when Its demand to a user to enter his credentials via the embedded browser, he can press the "return" button in his phone and he will be able to enter the site even if another user is connecting with the same credential in another pc ...!!!

Viewing all 2361 articles
Browse latest View live


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