I have an ASP.NET web application and a Moodle 2.2 web application set up in my test environment. I am trying to query a Moodle web service (core_user_get_users_by_id) from my ASP.NET app, I get this error:
<?xml version="1.0" encoding="UTF-8" ?> <EXCEPTION class="webservice_access_exception"> <MESSAGE>Access control exception</MESSAGE> <DEBUGINFO>Invalid token - token not found</DEBUGINFO> </EXCEPTION>
I have created the token, and associated it with my wsuser (web services user account) in Moodle, and I have run the web service successfully through Moodle's web service test client.
I have obtained a token via the admin interface, and also via login/token.php (as referenced here: http://docs.moodle.org/dev/Creating_a_web_service_client#How_to_get_a_user_token). Interestingly, I get different values. I also set up the shortname value for the web service (directly in the DB because there is no field in the Moodle 2.2 website for that value).
I'm guessing that the QueryString I am posting to the Moodle web service is incorrect. I've tried all combinations of the the following six parameters without success:
//Possible QueryString parameters for call to webservice "core_user_get_users_by_id".
"&token=" + token +
"&wstoken=" + token + // wstoken is used by the Moodle test client, but token is correct per documentation.
"&username=" + username + // my "web services user" in moodle.
"&servicename=view_user_details" + // view_user_details is the webservice shortname value I set.
"&userids=" + userid;
The last parameter name, userids, I got by using the input parameter name used by Moodle's web service test client's form. I obviously need to pass a userid for the query, but I cannot find a clear example in any of the Moodle docs.
I would be grateful for any help on this problem.