1

I am trying to register a user via API using Python Request.

Here is my code

import requests

url = "www.website.com/webservice/rest/server.php?createpassword=1&username=thisissifumwike&auth=manual&password=Tester@2023.&firstname=Domain&lastname=Tester&email=hello@gmail.com&maildisplay=sifugmail&city=Daressalaam&country=Tanzania&timezone=99&description=I am a good tester&firstnamephonetic=Sifu&lastnamephonetic=Domain&middlename=Tester&alternatename=Tunety&interests=books, codes, forex&idnumber=FMM001&institution=FMM&department=Traders&phone1=0611222333&phone2=0611333222&address=Daressalaam&lang=en&calendartype=gregorian&theme=default&mailformat=1&customfields=&wstoken=token&wsfunction=core_user_create_users&moodlewsrestformat=json"

payload={}
headers = {}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

However upon sending that request I get this response

{
    "exception": "invalid_parameter_exception",
    "errorcode": "invalidparameter",
    "message": "Invalid parameter value detected"
}

1 Answers1

0

URL must be something like this

www.website.com/webservice/rest/server.php?wstoken=THESERVICETOKEN&wsfunction=core_user_create_users&moodlewsrestformat=json&users[0][username]=USERNAME&users[0][password]=pdelis1!Pdelis&users[0][firstname]=FIRSTNAME&users[0][lastname]=PASSWORD&users[0][email]=EMAIL

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jul 05 '23 at 17:59
  • This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/34638953) – sanitizedUser Jul 07 '23 at 12:28