Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to POST a request on Moodle using POSTMAN api tool

I want to create an API request in Postman that creates a category in Moodle. The following are the steps which I did in Moodle :

  1. Enabled Web service
  2. Created an External service and added core_course_create_categories function.
  3. Enabled REST protocol
  4. Created Token.

This is my POST URL: http://localhost/test/moodle/webservice/rest/server.php?username=admin&password=Password@1&service=mycustomservice&name=CustomCategory&parent=1&idnumber=CSTM1&description=Desc

Under Authorization tab, I have selected Bearer Token and added the Token from Moodle web service.

When I send the request, I am getting invalidtoken Invalid token - token not found error.

Can anyone please suggest a solution for this

Moodle version: 3.4.8 and Postman version 7.6.0

Thanks in advance.

like image 235
Sarath Avatar asked Mar 11 '26 09:03

Sarath


1 Answers

You can not call API by GET Method. In postman you have to call the API using POST method. pass your token in form-data as wstoken. call your function as wsfunction.

Check my Screenshot below. enter image description here

like image 53
Sonil Gandhi Avatar answered Mar 15 '26 21:03

Sonil Gandhi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!