Creating users via API

Creating users via API

by Cypher Cypher -
Number of replies: 3
I am attempting to create users via the Moodle REST API, however, regardless of following the documentation and a ton of research, every time I send the request off in say Postman or trigger my n8n automation to generate users, it returns HTML which translates into the login page saying "You're not logged in (Log in)".  I've tried pretty much everything I've found and I can't seem to figure it out.  Any help would be great!
Average of ratings: -
In reply to Cypher Cypher

Re: Creating users via API

by Kodexo Labs -

Hello,

Congratulations on your project's one-year anniversary! Concerning the Moodle API issue, it appears to be an authentication issue. Make sure your requests include the appropriate authentication tokens or credentials. Check your API endpoint, headers, and payload for accuracy. If the problem persists, go at the API logs for more information. Please offer any extra information if you require it. Furthermore, AI software development company can help to improve automation and streamline business processes.


In reply to Cypher Cypher

Re: Creating users via API

by don mega -
at first you need to create a token for access API

use command curl for example or Postman, etc
curl -d username="student" -d password="sandbox"  "https://sandbox.moodledemo.net/login/token.php?service=moodle_mobile_app"

i use VSC extension "rest client":

###
?wstoken=695648fd6a1a06308823fa6dd9f338c8
&courseid=2
&moodlewsrestformat=json
&wsfunction=core_course_get_contents






In reply to Cypher Cypher

Re: Creating users via API

by Raj Sanghvi -

Creating users via API offers several benefits, including:

Efficiency: APIs enable the creation of users with minimal manual intervention, streamlining the user registration process and reducing the workload for the development team

Automation: APIs can automate the user creation process, allowing for faster and more efficient processing of user data

Integration: APIs can be used to integrate user data and functionality from various sources, ensuring a seamless and consistent user experience across different platforms and devices

Personalization: APIs enable the use of personalized data and content, tailoring the user experience to individual preferences and needs

Security: APIs can help ensure the security of user data by implementing strong authentication and authorization mechanisms, as well as protecting against custom web development vulnerabilities

Customization: APIs allow developers to access and use data and functionality from other applications, fostering innovation and enabling the creation of unique and tailored user experiences

By leveraging the benefits of creating users via API, businesses can enhance their user registration processes, improve user engagement, and foster innovation within their applications or systems.