Skip to main content
pdf?stylesheet=default
Blackboard Help

Examples: Upload Files, Get, and Handle Commands

This section includes examples of the CSV file formats and the XML file formats if you upload files. For administrators that update Moodle via web services, this section also contains examples of get and handle commands, plus PHP and ASP.net web service codes.


CSV File Formats

Any records from the Conduit tables can be exported in CSV and Excel formats. The data that will be exported is the data that matches the filter settings. To export the table data, click on the Export drop-down menu and select the file format you want to export to. A save dialog will then appear based on your browser.

  • Course: Create, update, and delete courses.

  • User: Create, update, and delete users.

  • Course Enrollment: Create, update, and delete enrollments.

  • Assign a Parent to a User: Create, update, and delete role assignments.

  • Groups: Create, update, and delete groups.

  • Group Members: Create, update, and delete group members.


XML File Formats

Course: Create, update, and delete courses.

<?xml version="1.0" encoding="UTF-8"?>
<data>
<datum action="create">
        <mapping name="shortname">BUS_101</mapping>
        <mapping name="category">Business_Administration</mapping>
        <mapping name="fullname">Introduction to Business</mapping>
        <mapping name="idnumber">40056</mapping>
        <mapping name="format">Topic</mapping>
        <mapping name="template">BUS_Template</mapping>
        <mapping name="visibility">Yes</mapping>
        <mapping name="startdate">integer</mapping>
    </datum>
    <datum action="update">
        <mapping name="shortname">BIO_101</mapping>
        <mapping name="fullname">Introduction to Biology</mapping>
    </datum>
    <datum action="delete">
        <mapping name="shortname">ENGL_101</mapping>
    </datum>
</data>

User:Create, update, and delete users.

<?xml version="1.0" encoding="UTF-8"?>
<data>
    <datum action="create">
        <mapping name="username">joesmith</mapping>
        <mapping name="firstname">Joe</mapping>
        <mapping name="lastname">Smith</mapping>
        <mapping name="email">joesmith@example.com</mapping>
        <mapping name="password">changeme</mapping>
    </datum>
    <datum action="update">
        <mapping name="username">tom</mapping>
        <mapping name="firstname">Tommy</mapping>
    </datum>
    <datum action="delete">
        <mapping name="username">bob</mapping>
    </datum>
</data>

Course Enrollment: Create, update, and delete enrollments.

<?xml version="1.0" encoding="UTF-8"?>
<data>
    <datum action="create">
        <mapping name="course">conduitcourse0</mapping>
        <mapping name="user">user0</mapping>
        <mapping name="role">student</mapping>
        <mapping name="status">1</mapping>
    </datum>
    <datum action="update">
        <mapping name="course">conduitcourse0</mapping>
        <mapping name="user">user0</mapping>
        <mapping name="role">student</mapping>
        <mapping name="status">0</mapping>
    </datum>
    <datum action="delete">
        <mapping name="course">conduitcourse0</mapping>
        <mapping name="user">user0</mapping>
    </datum>
</data>

Assign Parent to a User: Create, update, and delete enrollments.

<?xml version="1.0" encoding="UTF-8"?>
<data>
    <datum action="create">
        <mapping name="context">user</mapping>
        <mapping name="moodlekey">user0</mapping>
        <mapping name="user">parent0</mapping>
        <mapping name="role">editingteacher</mapping>
    </datum>
</data>
<?xml version="1.0" encoding="UTF-8"?>
<data>
    <datum action="update">
        <mapping name="context">user</mapping>
        <mapping name="moodlekey">user0</mapping>
        <mapping name="user">parent0</mapping>
        <mapping name="role">editingteacher</mapping>
    </datum>
</data>
<?xml version="1.0" encoding="UTF-8"?>
<data>
    <datum action="delete">
        <<mapping name="context">user</mapping>
        <mapping name="moodlekey">user0</mapping>
        <mapping name="user">parent0</mapping>
        <mapping name="role">editingteacher</mapping>
    </datum>
</data>

Groups: Create, update, and delete groups.

<?xml version="1.0" encoding="UTF-8"?>
<data>
    <datum action="create">
        <mapping name="course">testcourse</mapping>
        <mapping name="group">testgroup</mapping>
        <mapping name="description">This is a test Conduit group</mapping>
    </datum>
    <datum action="update">
        <mapping name="course">testcourse</mapping>
        <mapping name="group">testgroup</mapping>
        <mapping name="newgroup">testgroup2</mapping>
        <mapping name="description">This is a test Conduit group update</mapping>
    </datum>
    <datum action="delete">
        <mapping name="course">testcourse</mapping>
        <mapping name="group">testgroup</mapping>
    </datum>
</data>

Group Members: Create, update, and delete group members.

<?xml version="1.0" encoding="UTF-8"?>
<data>
    <datum action="create">
        <mapping name="course">testcourse</mapping>
        <mapping name="user">testuser</mapping>
        <mapping name="group">testgroup</mapping>
    </datum>
    <datum action="update">
        <mapping name="course">testcourse</mapping>
        <mapping name="user">testuser</mapping>
        <mapping name="group">testgroup</mapping>
    </datum>
    <datum action="delete">
        <mapping name="course">testcourse</mapping>
        <mapping name="user">testuser</mapping>
        <mapping name="group">testgroup</mapping>
    </datum>
</data>

Conduit Web Services

The Conduit RESTful Web service is broken up into different Web service end points:

  1. course
  2. enroll
  3. groups
  4. group_members
  5. role_assign
  6. user

Each Conduit RESTful Web service is called from an HTTPS URL. An example URL is:

https://{site}/blocks/conduit/webservices/rest/{service_name}.php?method=handle&token=TOKENVAL&xml=XMLSTRING

The site would be replaced with the client’s Moodlerooms site URL – usually something like clientname.mrooms.net. The service_name would be replaced with either user, course, enroll, groups or group_members.

Each of the Conduit RESTful Web services require two HTML post variables to be passed via an HTTPS call. These variables are:

  • string token: (Required) Set to the Token setting value used in Conduit Settings tab > Web services sub-tab.
  • string method: (Required) Must be set to the name of the method being called.

Get and Handle Command Methods for Web Services

Basic Structure

The basic XML structure for all requests to all endpoints that use the "handle" method is as follows:

<?xml version='1.0'?>
   <data>
     <datum action="{action}">
       <mapping name="{mappingname}">{value}</mapping>
     </datum>
     <datum action="{action}">
       <mapping name="{mappingname}">{value}</mapping>
     </datum>
   </data>

There are three variable values within this basic structure: action, mappingname. and value. The action variable contains the action that you want Conduit to execute. The mappingname is the value of the mapped field in Conduit that the value variable will set. For example, if I wanted to update the mapped field named “username” to “johndoe,” my XML would look like:

<?xml version='1.0'?>
   <data>
     <datum action="{action}">
         <mapping name="username">johndoe</mapping>
     </datum>
   </data>

Each XML request can have datum with their own actions, and an XML file can mix action types as well.

The Conduit’s XML response structure looks like the following. Each Web service endpoint will respond in a similar manner. The only part that will change is the service name variable in the structure below. This value will be the name of the endpoint.

<xml version='1.0'?>
<Service_{service name} generator="zend" version="1.0">
    <handle>
        <message> String(All Errors)</message>
        <status> Integer (1 or 0)</status>
    </handle>
</Service_Rest_{service name}>

User Web Service

End Point

https://<site>/blocks/conduit/webservices/rest/user.php

Methods

GET_USER

Get a Moodle user's profile data with custom profile fields.

POST PARAMETERS:

  • string token: (Required) Set to the Token setting value used in Conduit Settings tab > Web services sub-tab.
  • string method: (Required) Must be set to get_user.
  • string value: (Required) The user value to lookup, such as the user's name.
  • string field: (Optional, Default: username) The Moodle table field to look up against. Can be id, username, idnumber or email.

RETURNED XML SCHEMA

<?xml version="1.0" encoding="UTF-8"?>
<Service_User generator="zend" version="1.0">
  <get_user>
    <user>
      <id>int</id>
      <auth>string<auth>
      <confirmed>int</confirmed>
      <policyagreed>int</policyagreed>
      <deleted>int</deleted>
      <mnethostid>int</mnethostid>
      <username>string</username>
      <idnumber>string</idnumber>
      <firstname>string</firstname>
      <lastname>string</lastname>
      <email>string</email>
      <emailstop>int</emailstop>
      <icq>string</icq>
      <skype>string</skype>
      <yahoo>string</yahoo>
      <aim>string</aim>
      <msn>string</msn>
      <phone1>string</phone1>
      <phone2>string</phone2>
      <institution>string</institution>
      <department>string</department>
      <address>string</address>
      <city>string</city>
      <country>string</country>
      <lang>string</lang>
      <theme>string</theme>
      <timezone>int</timezone>
      <firstaccess>int</firstaccess>
      <lastaccess>int</lastaccess>
      <lastlogin>int</lastlogin>
      <currentlogin>int</currentlogin>
      <picture>int</picture>
      <url>string</url>
      <description>string</description>
      <mailformat>int</mailformat>
      <maildigest>int</maildigest>
      <maildisplay>int</maildisplay>
      <htmleditor>int</htmleditor>
      <ajax>int</ajax>
      <autosubscribe>int</autosubscribe>
      <trackforums>int</trackforums>
      <timemodified>int</timemodified>
      <trustbitmask>int</trustbitmask>
      <imagealt>string</imagealt>
      <screenreader>int</screenreader>
    </user>
    <status>success</status>
  </get_user>
</Service_User>
GET_USER_COURSE_RECENT_ACTIVITY

The Conduit user web service method get_user_course_recent_activity provides an external interface to retrieve information about all activities that have been added, updated or deleted for a period of time within the courses a user is enrolled in.

POST PARAMETERS

  • string token: (Required) Set to the Token setting value used in Conduit Settings tab > Web services sub-tab.
  • string method: (Required) Must be set to get_user_course_recent_activity.
  • string username: (Required) The user's user name.
  • string course: (Optional, Default: NULL) The course's ID number - if not passed, all user courses are returned.
  • int fromdate: (Optional, Default: NULL) UNIX time stamp of the start date.

RETURNED XML FORMAT

<?xml version="1.0" encoding="UTF-8"?>
<Service_User generator="zend" version="1.0">
  <get_user_course_recent_activity>
    <courses>
      <course>
        <id>integer</id>
        <fullname>string</fullname>
        <shortname>string</shortname>
        <idnumber>string</idnumber>
        <url>string</url>
        <visible>int</visible>
        <activities>
          <activity>
            <id>integer</id>
            <type>string</type>
            <name>string</name>
            <timestamp>integer(unixtimestamp)</timestamp>
            <descriptionhtml>string(html)/descriptionhtml>
            <descriptiontext>string</descriptiontext>
            <url>string</url>
          </activity>
        </activities>
      </course>
    </courses>
    <status>success/fail</status>
  </get_user_course_recent_activity>
</Service_User>

EXAMPLE RETURN XML

<?xml version="1.0" encoding="UTF-8"?>
<Service_User generator="zend" version="1.0">
  <get_user_course_recent_activity>
    <courses>
      <course>
        <id>12088</id>
        <fullname>Reporting Course</fullname>
        <shortname>REPO</shortname>
        <idnumber>IDNUM</idnumber>
        <url>
http://example.com/course/view.php?id=12088</url>
      <visible>1</visible>
        <activities>
          <activity>
            <id>6114</id>
            <type>assignment</type>
            <name>Not graded</name>
            <timestamp>1245093524</timestamp>
            <descriptionhtml>Added Assignment by Admin User:<a href="http://example.com/mod/assignment/view.php?id=6114"></descriptionhtml>
            <descriptiontext>Added Assignment by Admin User: Not graded</descriptiontext>
            <url>http://example.com/mod/assignment/view.php?id=6114</url>
           </activity>
          <activity>
            <id>6115</id>
            <type>assignment</type>
            <name>Graded</name>
            <timestamp>1245093540</timestamp>
            <descriptionhtml>Added Assignment by Admin User:<a href="http://example.com/mod/assignment/view.php?id=6115></descriptionhtml>             <descriptiontext>Added Assignment by Admin User: Graded</descriptiontext>
            <url>http://example.com/mod/assignment/view.php?id=6115</url>
           </activity>
          <activity>
            <id>6116</id>
            <type>quiz</type>
            <name>Graded quiz</name>
            <timestamp>1245093564</timestamp>
            <descriptionhtml>Added Quiz by Admin User:<a href="http://example.com/mod/quiz/view.php?id=6116"></descriptionhtml>
            <descriptiontext>Added Quiz by Admin User: Graded quiz</descriptiontext>
            <url>http://example.com/mod/quiz/view.php?id=6116</url>
           </activity>
          <activity>
            <id>6117</id>
            <type>quiz</type>
            <name>Not graded quiz</name>
            <timestamp>1245093655</timestamp>
            <descriptionhtml>Added Quiz by Admin User:<a href="http://example.com/mod/quiz/view.php?id=6117"></descriptionhtml>
            <descriptiontext>Added Quiz by Admin User: Not graded quiz</descriptiontext>
            <url>http://example.com/mod/quiz/view.php?id=6117</url>
           </activity>
        </activities>
      </course>
    </courses>
    <status>success</status>
  </get_user_course_recent_activity>
</Service_User>
GET_USER_COURSE_ACTIVITIES_DUE

The Conduit User web service's get_user_course_activities_due method provides external access to the activities that a user has due in a course within a given time period.

POST PARAMETERS

  • string token: (Required) Set to the Token setting value used in Conduit Settings tab > Web services sub-tab.
  • string method: (Required) Must be set to get_user_course_activities_due.
  • string username: (Required) The user's username.
  • int todate: (Required) Unix timestamp of the end date.
  • string course: (Optional, default = NULL) The course's idnumber - if not passed, all user courses are returned.

RETURNED XML FORMAT

<?xml version="1.0" encoding="UTF-8"?>
<Service_User generator="zend" version="1.0">
  <get_user_course_activities_due>
    <courses>
      <course>
        <id>integer</id>
        <fullname>string</fullname>
        <shortname>string</shortname>
        <idnumber>string</idnumber>
        <url>string</url>
        <activities>
          <activity>
            <id>integer</id>
            <type>string</type>
            <name>string</name>
            <descriptionhtml>string(html)</descriptionhtml>
            <descriptiontext>string</descriptiontext>
            <duedate>integer(unixtimestamp)</duedate>
            <url>string</url>
          </activity>
        </activities>
      </course>
    </courses>
    <status>success/fail</status>
  </get_user_course_activities_due>
</Service_User>

EXAMPLE RETURN XML

<?xml version="1.0" encoding="UTF-8"?>
<Service_User generator="zend" version="1.0">
  <get_user_course_activities_due>
    <courses>
      <course>
        <id>12088</id>
        <fullname>Reporting Course</fullname>
        <shortname>REPO</shortname>
        <idnumber>IDNUM</idnumber>
        <url>http://example.com/course/view.php?id=12088</url>
         <activities>
          <activity>
            <id>7797</id>
            <type>quiz</type>
            <name>Another quiz</name>
            <descriptionhtml>&lt;p&gt;asdf &lt;/p&gt;</descriptionhtml>
            <descriptiontext>asdf</descriptiontext>
            <duedate>0</duedate>
            <url>http://example.com/mod/quiz/view.php?id=7797</url>
           </activity>
          <activity>
            <id>6114</id>
            <type>assignment</type>
            <name>Not graded</name>
            <descriptionhtml>&lt;p&gt; Descasdf&lt;/p&gt;</descriptionhtml>
            <descriptiontext>Descasdf</descriptiontext>
            <duedate>1277234100</duedate>
            <url>http://example.com/mod/assignment/view.php?id=6114</url>
           </activity>
          <activity>
            <id>9103</id>
            <type>assignment</type>
            <name>eFolio</name>
            <descriptionhtml>&lt;p&gt; Introduction &lt;/p&gt;</descriptionhtml>
            <descriptiontext>Introduction</descriptiontext>
            <duedate>1306360800</duedate>
            <url>http://example.com/mod/assignment/view.php?id=9103</url>
           </activity>
        </activities>
      </course>
    </courses>
    <status>success</status>
  </get_user_course_activities_due>
</Service_User>
GET_USER_COURSE_EVENTS

The Conduit user Web service get_user_course_events method provides external access to the user's course events within a course. Please use the get_user_course_activities_due service to access activity due dates.

POST PARAMETERS

  • string token: (Required) Set to the Token setting value used in Conduit Settings tab > Web services sub-tab.
  • string method: (Required) Must be set to get_user_course_events.
  • string username: (Required) The user's user name.
  • int fromdate: (Required) UNIX timestamp of the start date.
  • int todate: (Required) UNIX timestamp of the end date.
  • string course: (Optional, Default: NULL ) The course's ID number - if not passed, all user courses are returned.

RETURNED XML FORMAT

<div><code>
<?xml version="1.0" encoding="UTF-8"?>
<Service_User generator="zend" version="1.0">
  <get_user_course_events>
    <courses>
      <course>
        <id>integer</id>
        <fullname>string</fullname>
        <shortname>string</shortname>
        <idnumber>string</idnumber>
        <url>string</url>
        <events>
          <event>
            <id>integer</id>
            <name>string</name>
            <timestart>integer(unix timestamp)</timestart>
            <timeend>integer(unix timestamp)</timeend>
            <description>string</description>
            <url>string</url>
          </event>
        </events>
      </course>
    </courses>
    <status>success</status>
  </get_user_course_events>
</Service_User>

EXAMPLE RETURN XML

<?xml version="1.0" encoding="UTF-8"?>
<Service_User generator="zend" version="1.0">
  <get_user_course_events>
    <courses>
      <course>
        <id>12088</id>
        <fullname>Reporting Course</fullname>
        <shortname>REPO</shortname>
        <idnumber>IDNUM</idnumber>
        <url>http://example.com/course/view.php?id=12088</url>
        <events>
          <event>
            <id>507</id>
            <name>Event 1</name>
            <timestart>1259827200</timestart>
            <timeend>1259827200</timeend>
            <description>This is the event.</description>
            <url>http://example.com/calendar/view.php?view=day&amp;amp;course=12088&amp;a...
          </event>
        </events>
      </course>
    </courses>
    <status>success</status>
  </get_user_course_events>
</Service_User>
GET_USER_GRADES

The Conduit user and course Web services provide external systems with a way to extract grades from Moodle. There are settings specifically for these services and they can be found in the Grades section under the Conduit Settings > Web services sub-tab. Conduit provides two endpoints to retrieve Moodle grades.

POST PARAMETERS:

  • string token: (Required) Set to the Token setting value used in Conduit Settings > Web services sub-tab.
  • string method: (Required) Must be set to get_user_grades.
  • string user: (Required) The user to return the grades for.
  • int batchsize: (Optional) The number of grades to return. Must be less than 10,000.
  • int lastprocessedid: (Optional) The last grade ID processed and returned from the Web service. This helps with crawling through all of the Moodle grades because if you pass it, the service will only return grades with IDs that are greater than this one.
  • int starttime: (Optional) Use to get grades that have been modified after this time. Pass in the form of a UNIX time stamp.
  • int endtime: (Optional) Use to get grades that have been modified before this time. Pass in the form of a UNIX time stamp.
  • string course: (Optional) Use to get the grades from a specific course for the user. The value must be either course shortname or idnumber based on the "Course ID" setting found in Conduit Settings > General sub-tab. If omitted, all user grades are returned.
  • string itemtypes: (Optional, Default: DEFAULT_SET) Pass a CSV list of grade item types to include. For all item types, pass an empty string. To get the default grade items that are configured through Conduit, do not pass this parameter or set it to DEFAULT_SET.

RETURNED XML SCHEMA

Both grade Web services endpoints return the same XML schema. The schema returns the grade items and their grades. The user and course tags act like dictionaries, as they contain all of the users and courses that the grade items and grades belong to. Use the courseid and the userid tags to look up their corresponding courses and users. The lastprocessedid tag is the last grade ID that the Web service processed. Use this value if you wish to use the lastprocessedid Web service parameter.

<?xml version="1.0" encoding="UTF-8"?>
<Service_User generator="zend" version="1.0">
  <get_user_grades>
    <users>
      <id_X>
        <user>
          <id>integer</id>
          <fullname>string</fullname>
          <username>string</username>
          <idnumber>string</idnumber>
        </user>
      </id_X>
    </users>
    <courses>
      <id_X>
        <course>
          <id>integer</id>
          <fullname>string</fullname>
          <shortname>string</shortname>
          <idnumber>string</idnumber>
        </course>
      </id_X>
    </courses>
    <gradeitems>
      <gradeitem>
        <courseid>integer</courseid>
        <itemtype>string(course, mod, category, manual, null)</itemtype>
        <itemname>string</itemname>
        <itemmodule>string</itemmodule>
        <iteminstance>integer</iteminstance>
        <grades>
          <grade>
            <id>integer</id>
            <userid>integer</userid>
            <finalgrade>number</finalgrade>
            <gradeletter>string</gradeletter>
            <gradepercent>string</gradepercent>
            <timemodified>integer</timemodified>
            <deleted>1/0</deleted>
          </grade>
        </grades>
      </gradeitem>
    </gradeitems>
    <lastprocessedid>integer</lastprocessedid>
    <status>success/fail</status>
  </get_user_grades>
</Service_User>

item types: course, mod, category, manual, null

Handle

POST PARAMETERS

  • string token: (Required) Set to the Token setting value used in Conduit Settings > Web services sub-tab.
  • string method: (Required) Must be set to handle.
  • string xml: (Required) XML schema that contains data for performing operations on Conduit records.

VALID ACTIONS

  • Create
  • Update
  • Delete

CREATE ACTION XML DEFINITION

<?xml version="1.0" encoding="UTF-8"?>
<data>
    <datum action="create">
        <mapping name="username">string</mapping>
        <mapping name="auth">string</mapping>
        <mapping name="mnethostid">integer</mapping>
        <mapping name="password">string</mapping>
        <mapping name="idnumber">string</mapping>
        <mapping name="firstname">string</mapping>
        <mapping name="lastname">string</mapping>
        <mapping name="email">string</mapping>
        <mapping name="emailstop">integer</mapping>
        <mapping name="icq">string</mapping>
        <mapping name="skype">string</mapping>
        <mapping name="yahoo">string</mapping>
        <mapping name="aim">string</mapping>
        <mapping name="man">string</mapping>
        <mapping name="phone1">string</mapping>
        <mapping name="phone2">string</mapping>
        <mapping name="institution">string</mapping>
        <mapping name="department">string</mapping>
        <mapping name="address">string</mapping>
        <mapping name="city">string</mapping>
        <mapping name="country">string</mapping>
        <mapping name="lang">string</mapping>
        <mapping name="theme">string</mapping>
        <mapping name="timezone">string</mapping>
        <mapping name="picture">integer</mapping>
        <mapping name="url">string</mapping>
        <mapping name="description">string</mapping>
        <mapping name="mailformat">integer</mapping>
        <mapping name="maildigest">integer</mapping>
        <mapping name="maildisplay">integer</mapping>
        <mapping name="htmleditor">integer</mapping>
        <mapping name="ajax">integer</mapping>
        <mapping name="autosubscribe">integer</mapping>
        <mapping name="trackforums">string</mapping>
        <mapping name="imagealt">integer</mapping>
        <mapping name="screenreader">integer</mapping>
        <mapping name="studentyear">string</mapping>
        <mapping name="textarea">string</mapping>
        <mapping name="managersemail">string</mapping>
    </datum>
</data>

UPDATE ACTION XML DEFINITION

<?xml version="1.0" encoding="UTF-8"?>
<data>
    <datum action="update">
        <mapping name="username">string</mapping>
        <mapping name="auth">string</mapping>
        <mapping name="mnethostid">integer</mapping>
        <mapping name="password">string</mapping>
        <mapping name="idnumber">string</mapping>
        <mapping name="firstname">string</mapping>
        <mapping name="lastname">string</mapping>
        <mapping name="email">string</mapping>
        <mapping name="emailstop">integer</mapping>
        <mapping name="icq">string</mapping>
        <mapping name="skype">string</mapping>
        <mapping name="yahoo">string</mapping>
        <mapping name="aim">string</mapping>
        <mapping name="man">string</mapping>
        <mapping name="phone1">string</mapping>
        <mapping name="phone2">string</mapping>
        <mapping name="institution">string</mapping>
        <mapping name="department">string</mapping>
        <mapping name="address">string</mapping>
        <mapping name="city">string</mapping>
        <mapping name="country">string</mapping>
        <mapping name="lang">string</mapping>
        <mapping name="theme">string</mapping>
        <mapping name="timezone">string</mapping>
        <mapping name="picture">integer</mapping>
        <mapping name="url">string</mapping>
        <mapping name="description">string</mapping>
        <mapping name="mailformat">integer</mapping>
        <mapping name="maildigest">integer</mapping>
        <mapping name="maildisplay">integer</mapping>
        <mapping name="htmleditor">integer</mapping>
        <mapping name="ajax">integer</mapping>
        <mapping name="autosubscribe">integer</mapping>
        <mapping name="trackforums">string</mapping>
        <mapping name="imagealt">integer</mapping>
        <mapping name="screenreader">integer</mapping>
        <mapping name="studentyear">string</mapping>
        <mapping name="textarea">string</mapping>
        <mapping name="managersemail">string</mapping>
    </datum>
</data>

DELETE ACTION XML DEFINITION

<?xml version="1.0" encoding="UTF-8"?>
<data>
    <datum action="delete">
        <mapping name="username">string</mapping>
    </datum>
</data>

RESPONSE XML DEFINITION

  <Service_User generator="zend" version="1.0">
    <handle>
        <message>MESSAGE</message>
        <status>STATUS</status>
    </handle>
</Service_Rest_User>

Course Web Services

End Point

https://<site>/blocks/conduit/webservices/rest/course.php

Methods

GET_COURSE

Get Moodle course settings.

POST PARAMETERS

  • string token: (Required) Set to the Token setting value used in Conduit Settings tab > Web services sub-tab.
  • string method: (Required) Must be set to get_course.
  • string value: (Required) The course value to lookup, such as the course's shortname.
  • string field: (Optional, default = shortname) The Moodle table field to lookup against. Can be id, shortname or idnumber.

RETURNED XML SCHEMA

<?xml version="1.0" encoding="UTF-8"?>
<Service_Course generator="zend" version="1.0">
  <get_course>
    <course>
      <id>int</id>
      <category>int</category>
      <sortorder>int</sortorder>
      <password>string</password>
      <fullname>string</fullname>
      <shortname>string</shortname>
      <idnumber>string</idnumber>
      <summary>string</summary>
      <format>string</format>
      <showgrades>int</showgrades>
      <newsitems>int</newsitems>
      <startdate>int</startdate>
      <enrolperiod>int</enrolperiod>
      <numsections>int</numsections>
      <marker>int</marker>
      <maxbytes>int</maxbytes>
      <showreports>int</showreports>
      <visible>int</visible>
      <hiddensections>int</hiddensections>
      <groupmode>int</groupmode>
      <groupmodeforce>int</groupmodeforce>
      <defaultgroupingid>int</defaultgroupingid>
      <lang>string</lang>
      <theme>string</theme>
      <timecreated>int</timecreated>
      <timemodified>int</timemodified>
      <requested>int</requested>
      <restrictmodules>int</restrictmodules>
    </course>
    <status>success</status>
  </get_course>
</Service_Course>
get_course_grades

The Conduit course Web services method get_course_grades provided external systems with a way to extract grades from Moodle.

There are settings specifically for the grades web services and are found in the Grades section under the Conduit Settings tab > Web services sub-tab.

get_course_grades returns all grades for all user's in the course even if they have been unenrolled from the course.

POST PARAMETERS

  • string token: (Required) Set to the Token setting value used in Conduit Settings tab > Web services sub-tab.
  • string method: (Required) Set to get_course_grades.
  • string course: (Optional) Use to get the grades from a specific course for the user. The value must be either course shortname or idnumber based on the Course ID setting found in Conduit Settings tab > General sub-tab. If omitted, all courses are returned.
  • int batchsize: (Optional) The number of grades to return. Must be less than 10,000.
  • int lastprocessedid: (Optional) The last grade ID processed and returned from the Web service. This helps with crawling through all of the Moodle grades because if you pass it, the service will only return grades with IDs that are greater than this one.
  • int starttime: (Optional) Use to get grades that have been modified after this time. Pass in the form of a UNIX time stamp.
  • int endtime: (Optional) Use to get grades that have been modified before this time. Pass in the form of a UNIX time stamp.
  • string itemtypes: (Optional, Default: DEFAULT_SET) Pass a CSV list of grade item types to include. For all item types, pass an empty string. To get the default grade items that are configured through Conduit, then do not pass this parameter or set it to DEFAULT_SET.

RETURNED XML SCHEMA

The schema returns the grade items and their grades. The user and course tags act like dictionaries, as they contain all of the users and courses that the grade items and grades belong to. Use the courseid and the userid tags to look up their corresponding courses and users. The lastprocessedid tag is the last grade ID that the Web service processed. Use this value if you wish to use the lastprocessedid Web service parameter.

<?xml version="1.0" encoding="UTF-8"?>
<Service_User generator="zend" version="1.0">
  <get_course_grades>
    <users>
      <id_X>
        <user>
          <id>integer</id>
          <fullname>string</fullname>
          <username>string</username>
          <idnumber>string</idnumber>
        </user>
      </id_X>
    </users>
    <courses>
      <id_X>
        <course>
          <id>integer</id>
          <fullname>string</fullname>
          <shortname>string</shortname>
          <idnumber>string</idnumber>
        </course>
      </id_X>
    </courses>
    <gradeitems>
      <gradeitem>
        <courseid>integer</courseid>
        <itemtype>string(course, mod, category, manual, null)</itemtype>
        <itemname>string</itemname>
        <itemmodule>string</itemmodule>
        <iteminstance>integer</iteminstance>
        <grades>
          <grade>
            <id>integer</id>
            <userid>integer</userid>
            <finalgrade>number</finalgrade>
            <gradeletter>string</gradeletter>
            <gradepercent>string</gradepercent>
            <timemodified>integer</timemodified>
            <deleted>1/0</deleted>
          </grade>
        </grades>
      </gradeitem>
    </gradeitems>
    <lastprocessedid>integer</lastprocessedid>
    <status>success/fail</status>
  </get_course_grades>
</Service_User>

Item types: course, mod, category, manual, null.

HANDLE

POST PARAMETERS

  • string token: (Required) Set to the Token setting value used in Conduit Settings tab > Web services sub-tab.
  • string method: (Required) Must be set to handle.
  • string xml: (Required) XML schema that contains data for performing operations on Conduit records.

VALID ACTIONS

  • Create
  • Update
  • Delete

CREATE ACTION XML DEFINITION

<?xml version="1.0" encoding="UTF-8"?>
<data>
    <datum action="create">
        <mapping name="shortname">string</mapping>
        <mapping name="category">string</mapping>
        <mapping name="password">string</mapping>
        <mapping name="fullname"><string/mapping>
        <mapping name="idnumber">string</mapping>
        <mapping name="summary">string</mapping>
        <mapping name="summaryformat">integer</mapping>
        <mapping name="format">string</mapping>
        <mapping name="showgrades">integer</mapping>
        <mapping name="newsitems">integer</mapping>
        <mapping name="startdate">integer</mapping>
        <mapping name="numsections">integer</mapping>
        <mapping name="marker">integer</mapping>
        <mapping name="maxbytes">integer</mapping>
        <mapping name="showreports">integer</mapping>
        <mapping name="visible">integer</mapping>
        <mapping name="hiddensections">integer</mapping>
        <mapping name="groupmode">integer</mapping>
        <mapping name="groupmodeforce">integer</mapping>
        <mapping name="defaultgroupingid"></mapping>
        <mapping name="lang">string</mapping>
        <mapping name="theme">string</mapping>
        <mapping name="requested">integer</mapping>
        <mapping name="restrictmodules">integer</mapping>
        <mapping name="enablecompletion">integer</mapping>
        <mapping name="completionstartonenrol">integer</mapping>
        <mapping name="completionnotify">integer</mapping>
        <mapping name="coursetemplate">string</mapping>
    </datum>
</data>

UPDATE ACTION XML DEFINITION

<?xml version="1.0" encoding="UTF-8"?>
<data>
    <datum action="update">
        <mapping name="shortname">string</mapping>
        <mapping name="category">string</mapping>
        <mapping name="password">string</mapping>
        <mapping name="fullname"><string/mapping>
        <mapping name="idnumber">string</mapping>
        <mapping name="summary">string</mapping>
        <mapping name="summaryformat">integer</mapping>
        <mapping name="format">string</mapping>
        <mapping name="showgrades">integer</mapping>
        <mapping name="newsitems">integer</mapping>
        <mapping name="startdate">integer</mapping>
        <mapping name="numsections">integer</mapping>
        <mapping name="marker">integer</mapping>
        <mapping name="maxbytes">integer</mapping>
        <mapping name="showreports">integer</mapping>
        <mapping name="visible">integer</mapping>
        <mapping name="hiddensections">integer</mapping>
        <mapping name="groupmode">integer</mapping>
        <mapping name="groupmodeforce">integer</mapping>
        <mapping name="defaultgroupingid"></mapping>
        <mapping name="lang">string</mapping>
        <mapping name="theme">string</mapping>
        <mapping name="requested">integer</mapping>
        <mapping name="restrictmodules">integer</mapping>
        <mapping name="enablecompletion">integer</mapping>
        <mapping name="completionstartonenrol">integer</mapping>
        <mapping name="completionnotify">integer</mapping>
        <mapping name="coursetemplate">string</mapping>
    </datum>
</data>

DELETE ACTION XML DEFINITION

<?xml version="1.0" encoding="UTF-8"?>
<data>
    <datum action="delete">
        <mapping name="shortname">string</mapping>
    </datum>
</data>

RESPONSE XML DEFINITION

<Service_Course generator="zend" version="1.0">
    <handle>
        <message>MESSAGE</message>
        <status>STATUS</status>
    </handle>
</Service_Rest_Course>

Enroll Web Service End Point

https://<site>/blocks/conduit/webservices/rest/enroll.php

Methods

HANDLE

POST PARAMETERS

  • string token: (Required) Set to the Token setting value used in Conduit Settings tab > Web services sub-tab.
  • string method: (Required) Must be set to handle.
  • string xml: (Required) XML schema that contains data for performing operations on Conduit records.

VALID ACTIONS

  • Create
  • Update
  • Delete

CREATE ACTION XML DEFINITION

<?xml version='1.0'?>
<data>
   <datum action="create">
     <mapping name="coursekey">string</mapping>
     <mapping name="userkey">string</mapping>
     <mapping name="rolekey">string</mapping>
     <mapping name="timestart">integer</mapping>
     <mapping name="timeend">integer</mapping>
   </datum>
</datum>
</data>

UPDATE ACTION XML DEFINITION

<?xml version='1.0'?>
<data>
   <datum action="update">
     <mapping name="coursekey">string</mapping>
     <mapping name="userkey">string</mapping>
     <mapping name="rolekey">string</mapping>
     <mapping name="timestart">integer</mapping>
     <mapping name="timeend">integer</mapping>
   </datum>
</datum>
</data>

DELETE ACTION XML DEFINITION

<?xml version='1.0'?>
<data>
   <datum action="delete">
     <mapping name="coursekey">string</mapping>
     <mapping name="userkey">string</mapping>
   </datum>
</data>

RESPONSE XML DEFINITION

<Service_Enrol generator="zend" version="1.0">
    <handle>
        <message>MESSAGE</message>
        <status>STATUS</status>
    </handle>
</Service_Rest_Enrol>

Role Assignment Web Service End Point

https://<site>/blocks/conduit/webservices/rest/role_assign.php

Methods

HANDLE

POST PARAMETERS

  • string token: (Required) Set to the Token setting value used in Conduit Settings tab > Web services sub-tab.
  • string method: (Required) Must be set to handle.
  • string xml: (Required) XML schema that contains data for performing operations on Conduit records.

VALID ACTIONS

  • Create
  • Update
  • Delete

CREATE ACTION XML DEFINITION

<?xml version='1.0'?>
<data>
   <datum action="create">
     <mapping name="context">course|user</mapping>
     <mapping name="moodlekey">string</mapping>
     <mapping name="userkey">string</mapping>
     <mapping name="rolekey">string</mapping>
     <mapping name="timestart">integer</mapping>
     <mapping name="timeend">integer</mapping>
   </datum>
</datum>
</data>

UPDATE ACTION XML DEFINITION

<?xml version='1.0'?>
<data>
   <datum action="update">
     <mapping name="context">course|user</mapping>
     <mapping name="moodlekey">string</mapping>
     <mapping name="userkey">string</mapping>
     <mapping name="rolekey">string</mapping>
     <mapping name="timestart">integer</mapping>
     <mapping name="timeend">integer</mapping>
   </datum>
</datum>
</data>

DELETE ACTION XML DEFINITION

<?xml version='1.0'?>
<data>
   <datum action="delete">
     <mapping name="context">course|user</mapping>
     <mapping name="moodlekey">string</mapping>
     <mapping name="userkey">string</mapping>
     <mapping name="rolekey">string</mapping>
   </datum>
</data>

RESPONSE XML DEFINITION

  <Service_Enrol generator="zend" version="1.0">
    <handle>
        <message>MESSAGE</message>
        <status>STATUS</status>
    </handle>
</Service_Rest_Enrol>

Groups Web Services

Endpoint

https://<site>/blocks/conduit/webservices/rest/groups.php

Methods

HANDLE

POST PARAMETERS

  • string token: (Required) Set to the Token setting value used in Conduit Settings tab > Web services sub-tab.
  • string method: (Required) Must be set to handle.
  • string xml: (Required) XML schema that contains data for performing operations on Conduit records.

VALID ACTIONS

  • Create
  • Update
  • Delete

CREATE ACTION XML DEFINITION

<?xml version="1.0" encoding="UTF-8"?>
<data>
    <datum action="create">
        <mapping name="coursekey">string</mapping>
        <mapping name="groupkey">string</mapping>
        <mapping name="description">string</mapping>
        <mapping name="enrollmentkey">string</mapping>
        <mapping name="hidepicture">integer</mapping>
    </datum>
</data>

UPDATE ACTION XML DEFINITION

<?xml version="1.0" encoding="UTF-8"?>
<data>
    <datum action="update">
        <mapping name="coursekey">string</mapping>
        <mapping name="groupkey">string</mapping>
        <mapping name="newgroupkey">string</mapping>
        <mapping name="description">string</mapping>
        <mapping name="enrollmentkey">string</mapping>
        <mapping name="hidepicture">integer</mapping>
    </datum>
</data>

DELETE ACTION XML DEFINITION

<?xml version="1.0" encoding="UTF-8"?>
<data>
    <datum action="delete">
        <mapping name="coursekey">string</mapping>
        <mapping name="groupkey">string</mapping>
    </datum>
</data>

RESPONSE XML DEFINITION

<Service_Groups generator="zend" version="1.0">
    <handle>
        <message>MESSAGE</message>
        <status>STATUS</status>
    </handle>
</Service_Rest_Groups>
GET_GROUPS

Get groups in a course.

POST PARAMETERS

  • string method: (Required) Must be set to get_groups.
  • string value: (Required) The course value to look up.
  • string field: (Optional, Default: idnumber) The course field to match the value against, can be id, shortname or idnumber.

RESPONSE XML DEFINITION

  <?xml version="1.0" encoding="UTF-8"?>
<Service_Groups generator="zend" version="1.0">
  <get_groups>
    <groups>
      <group>
        <courseid>int</courseid>
        <name>string</name>
        <description>string</description>
        <enrolmentkey>string</enrolmentkey>
        <picture>int</picture>
        <hidepicture>int</hidepicture>
        <timecreated>int</timecreated>
        <timemodified>int</timemodified>
        <id>int</id>
      </group>
    </groups>
    <status>success</status>
  </get_groups>
</Service_Groups>

Group Members Web Service Definition

Endpoint

https://<site>/blocks/conduit/webservices/rest/groups_members.php

Methods

HANDLE

POST PARAMETERS

  • string token: (Required) Set to the Token setting value used in Conduit Settings tab > Web services sub-tab.
  • string method: (Required) Must be set to get_user_course_events.
  • string xml: (Required) XML schema that contains data for performing operations on Conduit records.

VALID ACTIONS

  • Create
  • Delete

CREATE ACTION XML DEFINITION

<?xml version="1.0" encoding="UTF-8"?>
<data>
    <datum action="create">
        <mapping name="coursekey">string</mapping>
        <mapping name="userkey">string</mapping>
        <mapping name="groupkey">string</mapping>
    </datum>
</data>

DELETE ACTION XML DEFINITION

<?xml version="1.0" encoding="UTF-8"?>
<data>
    <datum action="delete">
        <mapping name="coursekey">string</mapping>
        <mapping name="userkey">string</mapping>
        <mapping name="groupkey">string</mapping>
    </datum>
</data>
RESPONSE XML DEFINITION
  <Service_group_members generator="zend" version="1.0">
    <handle>
        <message>MESSAGE</message>
        <status>STATUS</status>
    </handle>
</Service_Rest_GroupmMembers>

Conduit PHP Web Service Code Examples

Methods

get_user
<?php
    $baseDir = dirname(dirname(__FILE__));
   set_include_path(dirname($baseDir).'/lib/zend'. PATH_SEPARATOR.
                     "$baseDir/library". PATH_SEPARATOR.
                     "$baseDir/application/models". PATH_SEPARATOR.
                     get_include_path());
     
    require_once('Zend/Debug.php');
    require_once('Zend/Http/Client.php');
     
    $client = new Zend_Http_Client('http://{site}/blocks/conduit/webservices/rest/user.php');
   $client->setParameterPost(array('token'=>'<token>',
                    'method'=>'get_user',
                                    'username' => 'guest'
                   ));
   $response   = $client->request('POST');
    $lastrequest = $client->getLastRequest();
    $responsebody   = $response->getBody();
    $lastrequestbody = $lastrequest->getBody();
    echo '<pre>';
    print_r($lastrequestbody);
    echo '</pre>';
    echo '<pre>';
    print_r($responsebody);
    echo '</pre>';
    ?>
get_user_course_recent_activity
<?php
    $baseDir = dirname(dirname(__FILE__));
    set_include_path(dirname($baseDir).'/lib/zend'. PATH_SEPARATOR.
                     "$baseDir/library". PATH_SEPARATOR.
                     "$baseDir/application/models". PATH_SEPARATOR.
                     get_include_path());
     
    require_once('Zend/Debug.php');
    require_once('Zend/Http/Client.php');
     
    $client = new Zend_Http_Client('http://{site}/blocks/conduit/webservices/rest/user.php');
    $client->setParameterPost(array('token'=>'<token>',
                    'method'=>'get_user_course_recent_activity',
                                    'username' => 'guest'
                    ));
    $response = $client->request('POST');
    $lastrequest = $client->getLastRequest();
    $responsebody = $response->getBody();
    $lastrequestbody = $lastrequest->getBody();
    echo '<pre>';
    print_r($lastrequestbody);
    echo '</pre>';
    echo '<pre>';
    print_r($responsebody);
    echo '</pre>';
   ?>
get_user_course_activities_due
<?php
    $baseDir = dirname(dirname(__FILE__));
    set_include_path(dirname($baseDir).'/lib/zend'. PATH_SEPARATOR.
                     "$baseDir/library". PATH_SEPARATOR.
                     "$baseDir/application/models". PATH_SEPARATOR.
                     get_include_path());
     
    require_once('Zend/Debug.php');
    require_once('Zend/Http/Client.php');
     
    $client = new Zend_Http_Client('http://{site}/blocks/conduit/webservices/rest/user.php');
    $client->setParameterPost(array('token'=>'<token>',
                    'method'=>'get_user_course_activities_due',
                    'username' => 'guest',
                                    'todate' = time()
                    ));
    $response = $client->request('POST');
    $lastrequest = $client->getLastRequest();
    $responsebody = $response->getBody();
    $lastrequestbody = $lastrequest->getBody();
    echo '<pre>';
    print_r($lastrequestbody);
    echo '</pre>';
    echo '<pre>';
    print_r($responsebody);
    echo '</pre>';
    ?>
get_user_course_events
<?php
    $baseDir = dirname(dirname(__FILE__));
    set_include_path(dirname($baseDir).'/lib/zend'. PATH_SEPARATOR.
                     "$baseDir/library". PATH_SEPARATOR.
                     "$baseDir/application/models". PATH_SEPARATOR.
                     get_include_path());
     
    require_once('Zend/Debug.php');
    require_once('Zend/Http/Client.php');
     
    $client = new Zend_Http_Client('http://{site}/blocks/conduit/webservices/rest/user.php');
    $client->setParameterPost(array('token'=>'<token>',
                    'method'=>'get_user_course_events',
                    'field' =>'username',
                                    'value' => 'guest',
                                    'fromdata' => '1291506600';
                                    'todate' = time()
                    ));
    $response = $client->request('POST');
    $lastrequest = $client->getLastRequest();
    $responsebody = $response->getBody();
    $lastrequestbody = $lastrequest->getBody();
    echo '<pre>';
    print_r($lastrequestbody);
    echo '</pre>';
    echo '<pre>';
    print_r($responsebody);
    echo '</pre>';
   ?>
get_user_grades
  <?php
    $baseDir = dirname(dirname(__FILE__));
    set_include_path(dirname($baseDir).'/lib/zend'. PATH_SEPARATOR.
                     "$baseDir/library". PATH_SEPARATOR.
                     "$baseDir/application/models". PATH_SEPARATOR.
                     get_include_path());
     
    require_once('Zend/Debug.php');
    require_once('Zend/Http/Client.php');
     
    $client = new Zend_Http_Client('http://{site}/blocks/conduit/webservices/rest/user.php');
    $client->setParameterPost(array('token'=>'<token>',
                    'method'=>'get_user_grades',
                    'user.php' => 'test'
                    ));
    $response = $client->request('POST');
    $lastrequest = $client->getLastRequest();
    $responsebody = $response->getBody();
    $lastrequestbody = $lastrequest->getBody();
    echo '<pre>';
    print_r($lastrequestbody);
    echo '</pre>';
    echo '<pre>';
    print_r($responsebody);
    echo '</pre>';
    ?>
Handle

The following are examples of handle file that you use to create records.

Action Create

<?php
    $baseDir = dirname(dirname(__FILE__));
    set_include_path(dirname($baseDir).'/lib/zend'. PATH_SEPARATOR.
                     "$baseDir/library". PATH_SEPARATOR.
                     "$baseDir/application/models". PATH_SEPARATOR.
                     get_include_path());
     
    require_once('Zend/Debug.php');
    require_once('Zend/Http/Client.php');
     
    $xml = <<<XML
    <?xml version="1.0" encoding="UTF-8"?>
    <data>
        <datum action="create">
            <mapping name="username">testuser</mapping>
            <mapping name="password">testuser</mapping>
            <mapping name="idnumber">ts101</mapping>
            <mapping name="firstname">Test</mapping>
            <mapping name="lastname">User</mapping>
            <mapping name="email"> test@localhost.com</mapping>
            <mapping name="phone1">(123) 456-7891</mapping>
            <mapping name="phone2">(123) 456-7891</mapping>
            <mapping name="address">1234 Some Street</mapping>
            <mapping name="city">Baltimore</mapping>
            <mapping name="country">US</mapping>
        </datum>
    </data>

XML;

$client = new Zend_Http_Client('http://{site}/blocks/conduit/webservices/rest/user.php');
$client->setParameterPost(array('token'=>'<token>',
                'method'=>'handle',
                'xml'=>$xml
                ));
$response = $client->request('POST');
$lastrequest = $client->getLastRequest();
$responsebody = $response->getBody();
$lastrequestbody = $lastrequest->getBody();
echo '<pre>';
print_r($lastrequestbody);
echo '</pre>';
echo '<pre>';
print_r($responsebody);
echo '</pre>';
?>

Action Update

<?php
    $baseDir = dirname(dirname(__FILE__));
    set_include_path(dirname($baseDir).'/lib/zend'. PATH_SEPARATOR.
                     "$baseDir/library". PATH_SEPARATOR.
                     "$baseDir/application/models". PATH_SEPARATOR.
                     get_include_path());
     
    require_once('Zend/Debug.php');
    require_once('Zend/Http/Client.php');
     
    $xml = <<<XML
    <?xml version="1.0" encoding="UTF-8"?>
    <data>
        <datum action="update">
            <mapping name="username">testuser</mapping>
            <mapping name="password">testuser</mapping>
            <mapping name="idnumber">ts1012</mapping>
            <mapping name="firstname">Test</mapping>
            <mapping name="lastname">User</mapping>
            <mapping name="email">test@localhost.com</mapping>
            <mapping name="phone1">(123) 456-7891</mapping>
            <mapping name="phone2">(123) 456-7891</mapping>
            <mapping name="address">1234 Some Street</mapping>
            <mapping name="city">Baltimore</mapping>
            <mapping name="country">US</mapping>
        </datum>
    </data>

XML;

$client = new Zend_Http_Client('http://{site}/blocks/conduit/webservices/rest/user.php');
$client->setParameterPost(array('token'=>'<token>',
                'method'=>'handle',
                'xml'=>$xml
                ));
$response = $client->request('POST');
$lastrequest = $client->getLastRequest();
$responsebod = $response->getBody();
$lastrequestbody = $lastrequest->getBody();
echo '<pre>';
print_r($lastrequestbody);
echo '</pre>';
echo '<pre>';
print_r($responsebody);
echo '</pre>';
?>

Action Delete

<?php
    $baseDir = dirname(dirname(__FILE__));
    set_include_path(dirname($baseDir).'/lib/zend'. PATH_SEPARATOR.
                     "$baseDir/library". PATH_SEPARATOR.
                     "$baseDir/application/models". PATH_SEPARATOR.
                     get_include_path());
     
    require_once('Zend/Debug.php');
    require_once('Zend/Http/Client.php');
     
    $xml = <<<XML
    <?xml version="1.0" encoding="UTF-8"?>
    <data>
        <datum action="delete">
            <mapping name="username">testuser</mapping>
        </datum>
    </data>

XML;

$client = new Zend_Http_Client('http://{site}/blocks/conduit/webservices/rest/user.php');
$client->setParameterPost(array('token'=>'<token>',
                'method'=>'handle',
                'xml'=>$xml
                ));
$response    = $client->request('POST');
$lastrequest = $client->getLastRequest();
$responsebody    = $response->getBody();
$lastrequestbody = $lastrequest->getBody();
echo '<pre>';
print_r($lastrequestbody);
echo '</pre>';
echo '<pre>';
print_r($responsebody);
echo '</pre>';
?>

Course Web Service Examples

Methods

get_course
<?php
    $baseDir = dirname(dirname(__FILE__));
    set_include_path(dirname($baseDir).'/lib/zend'. PATH_SEPARATOR.
                     "$baseDir/library". PATH_SEPARATOR.
                     "$baseDir/application/models". PATH_SEPARATOR.
                     get_include_path());
     
    require_once('Zend/Debug.php');
    require_once('Zend/Http/Client.php');
     
    $client = new Zend_Http_Client('http://{site}/blocks/conduit/webservices/rest/course.php');
    $client->setParameterPost(array('token'=>'<token>',
                    'method'=>'handle',
                    'value'=>'CF101'
                    ));
    $response = $client->request('POST');
    $lastrequest = $client->getLastRequest();
    $responsebody = $response->getBody();
    $lastrequestbody = $lastrequest->getBody();
    echo '<pre>';
    print_r($lastrequestbody);
    echo '</pre>';
    echo '<pre>';
    print_r($responsebody);
    echo '</pre>';
    ?>
get_course_grades
<?php
    $baseDir = dirname(dirname(__FILE__));
    set_include_path(dirname($baseDir).'/lib/zend'. PATH_SEPARATOR.
                     "$baseDir/library". PATH_SEPARATOR.
                     "$baseDir/application/models". PATH_SEPARATOR.
                     get_include_path());
     
    require_once('Zend/Debug.php');
    require_once('Zend/Http/Client.php');
     
    $client = new Zend_Http_Client('http://{site}/blocks/conduit/webservices/rest/course.php');
    $client->setParameterPost(array('token'=>'<token>',
                    'method'=>'handle',
                    'course.php'=>'CF101'
                    ));
    $response = $client->request('POST');
    $lastrequest = $client->getLastRequest();
    $responsebody = $response->getBody();
    $lastrequestbody = $lastrequest->getBody();
    echo '<pre>';
    print_r($lastrequestbody);
    echo '</pre>';
    echo '<pre>';
    print_r($responsebody);
    echo '</pre>';
    ?>

Handle

The following are examples of handle file that you use to create records.

Action Create

<?php
    $baseDir = dirname(dirname(__FILE__));
    set_include_path(dirname($baseDir).'/lib/zend'. PATH_SEPARATOR.
                     "$baseDir/library". PATH_SEPARATOR.
                     "$baseDir/application/models". PATH_SEPARATOR.
                     get_include_path());
     
    require_once('Zend/Debug.php');
    require_once('Zend/Http/Client.php');
     
    $xml = <<<XML
    <?xml version="1.0" encoding="UTF-8"?>
    <data>
        <datum action="create">
            <mapping name="shortname">testcourse</mapping>
            <mapping name="fullname">Test Course</mapping>
            <mapping name="idnumber">test</mapping>
            <mapping name="summary">Web service test</mapping>
            <mapping name="enrolllable">1</mapping>
        </datum>
    </data>
XML;

$client = new Zend_Http_Client('http://{site}/blocks/conduit/webservices/rest/course.php');
$client->setParameterPost(array('token'=>'<token>',
                'method'=>'handle',
                'xml'=>$xml
                ));
$response    = $client->request('POST');
$lastrequest = $client->getLastRequest();
$responsebody    = $response->getBody();
$lastrequestbody = $lastrequest->getBody();
echo '<pre>';
print_r($lastrequestbody);
echo '</pre>';
echo '<pre>';
print_r($responsebody);
echo '</pre>';
?>

Action Update

<?php
    $baseDir = dirname(dirname(__FILE__));
    set_include_path(dirname($baseDir).'/lib/zend'. PATH_SEPARATOR.
                     "$baseDir/library". PATH_SEPARATOR.
                     "$baseDir/application/models". PATH_SEPARATOR.
                     get_include_path());
     
    require_once('Zend/Debug.php');
    require_once('Zend/Http/Client.php');
     
    $xml = <<<XML
    <?xml version="1.0" encoding="UTF-8"?>
    <data>
        <datum action="update">
            <mapping name="shortname">testcourse</mapping>
            <mapping name="fullname">Test Course</mapping>
            <mapping name="idnumber">test</mapping>
            <mapping name="summary">Web service test</mapping>
            <mapping name="enrolllable">1</mapping>
        </datum>
    </data>
XML;

$client = new Zend_Http_Client('http://{site}/blocks/conduit/webservices/rest/course.php');
$client->setParameterPost(array('token'=>'<token>',
                'method'=>'handle',
                'xml'=>$xml
                ));
$response    = $client->request('POST');
$lastrequest = $client->getLastRequest();
$responsebody    = $response->getBody();
$lastrequestbody = $lastrequest->getBody();
echo '<pre>';
print_r($lastrequestbody);
echo '</pre>';
echo '<pre>';
print_r($responsebody);
echo '</pre>';
?>

Action Delete

<?php
    $baseDir = dirname(dirname(__FILE__));
    set_include_path(dirname($baseDir).'/lib/zend'. PATH_SEPARATOR.
                     "$baseDir/library". PATH_SEPARATOR.
                     "$baseDir/application/models". PATH_SEPARATOR.
                     get_include_path());
     
    require_once('Zend/Debug.php');
    require_once('Zend/Http/Client.php');
     
    $xml = <<<XML
    <?xml version="1.0" encoding="UTF-8"?>
    <data>
        <datum action="delete">
            <mapping name="shortname">testcourse</mapping>
          </datum>
    </data>
XML;

$client = new Zend_Http_Client('http://{site}/blocks/conduit/webservices/rest/course.php');
$client->setParameterPost(array('token'=>'<token>',
                'method'=>'handle',
                'xml'=>$xml
                ));
$response = $client->request('POST');
$lastrequest = $client->getLastRequest();
$responsebody = $response->getBody();
$lastrequestbody = $lastrequest->getBody();
echo '<pre>';
print_r($lastrequestbody);
echo '</pre>';
echo '<pre>';
print_r($responsebody);
echo '</pre>';
?>

Enroll Web Service Examples

Handle

Action Add

<?php
    $baseDir = dirname(dirname(__FILE__));
    set_include_path(dirname($baseDir).'/lib/zend'. PATH_SEPARATOR.
                     "$baseDir/library". PATH_SEPARATOR.
                     "$baseDir/application/models". PATH_SEPARATOR.
                     get_include_path());
     
    require_once('Zend/Debug.php');
    require_once('Zend/Http/Client.php');
     
    $xml = <<<XML
    <?xml version="1.0" encoding="UTF-8"?>
    <data>
        <datum action="add">
              <mapping name="course">testcourse</mapping>
              <mapping name="username">testuser</mapping>
              <mapping name="role">student</mapping>
        </datum>
    </data>

XML;

$client = new Zend_Http_Client('http://{site}/blocks/conduit/webservices/rest/enroll.php');
$client->setParameterPost(array('token'=>'<token>',
                'method'=>'handle',
                'xml'=>$xml
                ));
$response = $client->request('POST');
$lastrequest = $client->getLastRequest();
$responsebody = $response->getBody();
$lastrequestbody = $lastrequest->getBody();
echo '<pre>';
print_r($lastrequestbody);
echo '</pre>';
echo '<pre>';
print_r($responsebody);
echo '</pre>';
?>

Action Drop

<?php
    $baseDir = dirname(dirname(__FILE__));
    set_include_path(dirname($baseDir).'/lib/zend'. PATH_SEPARATOR.
                     "$baseDir/library". PATH_SEPARATOR.
                     "$baseDir/application/models". PATH_SEPARATOR.
                     get_include_path());
     
    require_once('Zend/Debug.php');
    require_once('Zend/Http/Client.php');
     
    $xml = <<<XML
    <?xml version="1.0" encoding="UTF-8"?>
    <data>
        <datum action="drop">
              <mapping name="course">testcourse</mapping>
              <mapping name="username">testuser</mapping>
              <mapping name="role">student</mapping>
        </datum>
    </data>

XML;

$client = new Zend_Http_Client('http://{site}/blocks/conduit/webservices/rest/enroll.php');
$client->setParameterPost(array('token'=>'<token>',
                'method'=>'handle',
                'xml'=>$xml
                ));
$response = $client->request('POST');
$lastrequest = $client->getLastRequest();
$responsebody = $response->getBody();
$lastrequestbody = $lastrequest->getBody();
echo '<pre>';
print_r($lastrequestbody);
echo '</pre>';
echo '<pre>';
print_r($responsebody);
echo '</pre>';
?>

Role Assignment Web Service Examples

Handle

Action Add

<?php
    $baseDir = dirname(dirname(__FILE__));
    set_include_path(dirname($baseDir).'/lib/zend'. PATH_SEPARATOR.
                     "$baseDir/library". PATH_SEPARATOR.
                     "$baseDir/application/models". PATH_SEPARATOR.
                     get_include_path());
     
    require_once('Zend/Debug.php');
    require_once('Zend/Http/Client.php');
     
    $xml = <<<XML
    <?xml version="1.0" encoding="UTF-8"?>
    <data>
        <datum action="create">
              <mapping name="context">user</mapping>
              <mapping name="moodlekey">testuser</mapping>
              <mapping name="userkey">parent</mapping>
              <mapping name="rolekey">manager</mapping>
        </datum>
    </data>
XML;

$client = new Zend_Http_Client('http://{site}/blocks/conduit/webservices/rest/role_assign.php');
$client->setParameterPost(array('token'=>'<token>',
                'method'=>'handle',
                'xml'=>$xml
                ));
$response = $client->request('POST');
$lastrequest = $client->getLastRequest();
$responsebody = $response->getBody();
$lastrequestbody = $lastrequest->getBody();
echo '<pre>';
print_r($lastrequestbody);
echo '</pre>';
echo '<pre>';
print_r($responsebody);
echo '</pre>';
?>

Action Drop

<?php
    $baseDir = dirname(dirname(__FILE__));
    set_include_path(dirname($baseDir).'/lib/zend'. PATH_SEPARATOR.
                     "$baseDir/library". PATH_SEPARATOR.
                     "$baseDir/application/models". PATH_SEPARATOR.
                     get_include_path());
     
    require_once('Zend/Debug.php');
    require_once('Zend/Http/Client.php');
     
    $xml = <<<XML
    <?xml version="1.0" encoding="UTF-8"?>
    <data>
        <datum action="create">
          <mapping name="context">user</mapping>
          <mapping name="moodlekey">testuser</mapping>
              <mapping name="userkey">parent</mapping>
              <mapping name="rolekey">manager</mapping>
              <mapping name="timestart">1296762421</mapping>
              <mapping name="timeend">1296770000</mapping>
        </datum>
    </data>
XML;

$client = new Zend_Http_Client('http://{site}/blocks/conduit/webservices/rest/role_assign.php');
$client->setParameterPost(array('token'=>'<token>',
                'method'=>'handle',
                'xml'=>$xml
                ));
$response = $client->request('POST');
$lastrequest = $client->getLastRequest();
$responsebody = $response->getBody();
$lastrequestbody = $lastrequest->getBody();
echo '<pre>';
print_r($lastrequestbody);
echo '</pre>';
echo '<pre>';
print_r($responsebody);
echo '</pre>';
?>

Groups Web Service Examples

Method

get_groups
<?php
    $baseDir = dirname(dirname(__FILE__));
    set_include_path(dirname($baseDir).'/lib/zend'. PATH_SEPARATOR.
                     "$baseDir/library". PATH_SEPARATOR.
                     "$baseDir/application/models". PATH_SEPARATOR.
                     get_include_path());
     
    require_once('Zend/Debug.php');
    require_once('Zend/Http/Client.php');
     
    $client = new Zend_Http_Client('http://{site}/blocks/conduit/webservices/rest/groups.php');
    $client->setParameterPost(array('token'=>'<token>',
                                    'method'=>'get_groups',
                                    'shortname' => 'CF101'
                    ));
    $response    = $client->request('POST');
    $lastrequest = $client->getLastRequest();
    $responsebody    = $response->getBody();
    $lastrequestbody = $lastrequest->getBody();
    echo '<pre>';
    print_r($lastrequestbody);
    echo '</pre>';
    echo '<pre>';
    print_r($responsebody);
    echo '</pre>';
    ?>

Handle

get_user_grades

Action Create

<?php
    $baseDir = dirname(dirname(__FILE__));
    set_include_path(dirname($baseDir).'/lib/zend'. PATH_SEPARATOR.
                     "$baseDir/library". PATH_SEPARATOR.
                     "$baseDir/application/models". PATH_SEPARATOR.
                     get_include_path());
     
    require_once('Zend/Debug.php');
    require_once('Zend/Http/Client.php');
     
    $xml = <<<XML
    <?xml version="1.0" encoding="UTF-8"?>
<data>
    <datum action="create">
        <mapping name="course">testcourse</mapping>
        <mapping name="name">testgroup</mapping>
        <mapping name="description">This is a test Conduit group</mapping>
    </datum>
</data>

XML;

$client = new Zend_Http_Client('http://{site}/blocks/conduit/webservices/rest/groups.php');
$client->setParameterPost(array('token'=>'<token>',
                'method'=>'handle',
                'xml'=>$xml
                ));
$response = $client->request('POST');
$lastrequest = $client->getLastRequest();
$responsebody = $response->getBody();
$lastrequestbody = $lastrequest->getBody();
echo '<pre>';
print_r($lastrequestbody);
echo '</pre>';
echo '<pre>';
print_r($responsebody);
echo '</pre>';
?>

Action Update

<?php
    $baseDir = dirname(dirname(__FILE__));
    set_include_path(dirname($baseDir).'/lib/zend'. PATH_SEPARATOR.
                     "$baseDir/library". PATH_SEPARATOR.
                     "$baseDir/application/models". PATH_SEPARATOR.
                     get_include_path());
     
    require_once('Zend/Debug.php');
    require_once('Zend/Http/Client.php');
     
    $xml = <<<XML
    <?xml version="1.0" encoding="UTF-8"?>
<data>
    <datum action="update">
        <mapping name="course">testcourse</mapping>
        <mapping name="name">testgroup</mapping>
        <mapping name="newname">testgroup2</mapping>
        <mapping name="description">This is a test Conduit group update</mapping>
    </datum>
</data>

XML;

$client = new Zend_Http_Client('http://{site}/blocks/conduit/webservices/rest/groups.php');
$client->setParameterPost(array('token'=>'<token>',
                'method'=>'handle',
                'xml'=>$xml
                ));
$response = $client->request('POST');
$lastrequest = $client->getLastRequest();
$responsebody = $response->getBody();
$lastrequestbody = $lastrequest->getBody();
echo '<pre>';
print_r($lastrequestbody);
echo '</pre>';
echo '<pre>';
print_r($responsebody);
echo '</pre>';
?>

Action Delete

<?php
    $baseDir = dirname(dirname(__FILE__));
    set_include_path(dirname($baseDir).'/lib/zend'. PATH_SEPARATOR.
                     "$baseDir/library". PATH_SEPARATOR.
                     "$baseDir/application/models". PATH_SEPARATOR.
                     get_include_path());
     
    require_once('Zend/Debug.php');
    require_once('Zend/Http/Client.php');
     
    $xml = <<<XML
    <?xml version="1.0" encoding="UTF-8"?>
<data>
    <datum action="delete">
        <mapping name="course">testcourse</mapping>
        <mapping name="name">testgroup</mapping>
    </datum>
</data>

XML;

$client = new Zend_Http_Client('http://{site}/blocks/conduit/webservices/rest/groups.php');
$client->setParameterPost(array('token'=>'<token>',
                'method'=>'handle',
                'xml'=>$xml
                ));
$response = $client->request('POST');
$lastrequest = $client->getLastRequest();
$responsebody = $response->getBody();
$lastrequestbody = $lastrequest->getBody();
echo '<pre>';
print_r($lastrequestbody);
echo '</pre>';
echo '<pre>';
print_r($responsebody);
echo '</pre>';
?>

Group Members Web Service Examples

Handle

Action Create

<?php
    $baseDir = dirname(dirname(__FILE__));
    set_include_path(dirname($baseDir).'/lib/zend'. PATH_SEPARATOR.
                     "$baseDir/library". PATH_SEPARATOR.
                     "$baseDir/application/models". PATH_SEPARATOR.
                     get_include_path());
     
    require_once('Zend/Debug.php');
    require_once('Zend/Http/Client.php');
     
    $xml = <<<XML
    <?xml version="1.0" encoding="UTF-8"?>
<data>
    <datum action="create">
        <mapping name="course">testcourse</mapping>
        <mapping name="user">testuser</mapping>
        <mapping name="groupname">testgroup</mapping>
    </datum>
</data>

XML;

$client = new Zend_Http_Client('http://{site}/blocks/conduit/webservices/rest/groups_members.php');
$client->setParameterPost(array('token'=>'<token>',
                'method'=>'handle',
                'xml'=>$xml
                ));
$response    = $client->request('POST');
$lastrequest = $client->getLastRequest();
$responsebody    = $response->getBody();
$lastrequestbody = $lastrequest->getBody();
echo '<pre>';
print_r($lastrequestbody);
echo '</pre>';
echo '<pre>';
print_r($responsebody);
echo '</pre>';
?>

get_user_grades

<?php
    $baseDir = dirname(dirname(__FILE__));
    set_include_path(dirname($baseDir).'/lib/zend'. PATH_SEPARATOR.
                     "$baseDir/library". PATH_SEPARATOR.
                     "$baseDir/application/models". PATH_SEPARATOR.
                     get_include_path());
     
    require_once('Zend/Debug.php');
    require_once('Zend/Http/Client.php');
     
    $xml = <<<XML
    <?xml version="1.0" encoding="UTF-8"?>
<data>
    <datum action="delete">
        <mapping name="course">testcourse</mapping>
        <mapping name="user">testuser</mapping>
        <mapping name="groupname">testgroup</mapping>
    </datum>
</data>

XML;

$client = new Zend_Http_Client('http://{site}/blocks/conduit/webservices/rest/groups_members.php');
$client->setParameterPost(array('token'=>'<token>',
                'method'=>'handle',
                'xml'=>$xml
                ));
$response    = $client->request('POST');
$lastrequest = $client->getLastRequest();
$responsebody    = $response->getBody();
$lastrequestbody = $lastrequest->getBody();
echo '<pre>';
print_r($lastrequestbody);
echo '</pre>';
echo '<pre>';
print_r($responsebody);
echo '</pre>';
?>

Conduit ASP.Net Web Service Code Examples

User Web Service Examples

Methods

get_user
using System;
 
using System.Collections;
 
using System.Configuration;
 
using System.Data;
 
using System.Linq;
 
using System.Web;
 
using System.Web.Security;
 
using System.Web.UI;
 
using System.Web.UI.HtmlControls;
 
using System.Web.UI.WebControls;
 
using System.Web.UI.WebControls.WebParts;
 
using System.Xml.Linq;
 
using System.IO;
 
using System.Text;
 
using System.Xml;
 
using System.Net;
 
using System.Diagnostics;
 

public partial class TestPage : System.Web.UI.Page
 
{
 
    protected void Page_Load(object sender, EventArgs e)
 
    {
 

    }
 

    protected void btnSubmit_Click(object sender, EventArgs e)
 
    {
 
        string url = "http://{sitename}/blocks/conduit/webservices/rest/user.php", token = "{token}", response = "", user = “james”;
 
        string username = "guest";
 

        string postData = "method=get_user&token=" + token + "username="+username+"todate="+DateTime.Now.ToString();
 

        StreamWriter myWriter = null;
 
        HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url);
 
        objRequest.Method = "POST";
 
        objRequest.ContentType = "application/x-www-form-urlencoded";
 
        objRequest.ContentLength = postData.Length;
 

        if (sb.ToString() != "")
 
        {
 
            try
 
            {
 
                myWriter = new StreamWriter(objRequest.GetRequestStream());
 
                myWriter.Write(postData);
 
            }
 
            catch (Exception ex)
 
            {
 
                response = ex.Message;
 
            }
 
            finally
 
            {
 
                myWriter.Close();
 
            }
 
        }
 

        HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse();
 
        using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()))
 
        {
 
            response = sr.ReadToEnd();
 
            Response.Write(response);
 
            sr.Close(); // Close and clean up the StreamReader
 
        }
 
    }
 
}
 
get_user_course_recent_activity
using System;
 
using System.Collections;
 
using System.Configuration;
 
using System.Data;
 
using System.Linq;
 
using System.Web;
 
using System.Web.Security;
 
using System.Web.UI;
 
using System.Web.UI.HtmlControls;
 
using System.Web.UI.WebControls;
 
using System.Web.UI.WebControls.WebParts;
 
using System.Xml.Linq;
 
using System.IO;
 
using System.Text;
 
using System.Xml;
 
using System.Net;
 
using System.Diagnostics;
 

public partial class TestPage : System.Web.UI.Page
 
{
 
    protected void Page_Load(object sender, EventArgs e)
 
    {
 

    }
 

    protected void btnSubmit_Click(object sender, EventArgs e)
 
    {
 
        string url = "http://{sitename}/blocks/conduit/webservices/rest/user.php", token = "{token}", response = "", user = “james”;
 
        string username = "guest";
 

        string postData = "method=get_user_course_recent_activity&token=" + token + "username="+username+"todate="+DateTime.Now.ToString();
 

        StreamWriter myWriter = null;
 
        HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url);
 
        objRequest.Method = "POST";
 
        objRequest.ContentType = "application/x-www-form-urlencoded";
 
        objRequest.ContentLength = postData.Length;
 

        if (sb.ToString() != "")
 
        {
 
            try
 
            {
 
                myWriter = new StreamWriter(objRequest.GetRequestStream());
 
                myWriter.Write(postData);
 
            }
 
            catch (Exception ex)
 
            {
 
                response = ex.Message;
 
            }
 
            finally
 
            {
 
                myWriter.Close();
 
            }
 
        }
 

        HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse();
 
        using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()))
 
        {
 
            response = sr.ReadToEnd();
 
            Response.Write(response);
 
            sr.Close(); // Close and clean up the StreamReader
 
        }
 
    }
 
}
 
get_user_course_activities_due
using System;
 
using System.Collections;
 
using System.Configuration;
 
using System.Data;
 
using System.Linq;
 
using System.Web;
 
using System.Web.Security;
 
using System.Web.UI;
 
using System.Web.UI.HtmlControls;
 
using System.Web.UI.WebControls;
 
using System.Web.UI.WebControls.WebParts;
 
using System.Xml.Linq;
 
using System.IO;
 
using System.Text;
 
using System.Xml;
 
using System.Net;
 
using System.Diagnostics;
 

public partial class TestPage : System.Web.UI.Page
 
{
 
    protected void Page_Load(object sender, EventArgs e)
 
    {
 

    }
 

    protected void btnSubmit_Click(object sender, EventArgs e)
 
    {
 
        string url = "http://{sitename}/blocks/conduit/webservices/rest/user.php", token = "{token}", response = "", user = “james”;
 
        string username = "guest";
 

        string postData = "method=get_user_course_activities_due&token=" + token + "username="+username+"todate="+DateTime.Now.ToString();
 

        StreamWriter myWriter = null;
 
        HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url);
 
        objRequest.Method = "POST";
 
        objRequest.ContentType = "application/x-www-form-urlencoded";
 
        objRequest.ContentLength = postData.Length;
 

        if (sb.ToString() != "")
 
        {
 
            try
 
            {
 
                myWriter = new StreamWriter(objRequest.GetRequestStream());
 
                myWriter.Write(postData);
 
            }
 
            catch (Exception ex)
 
            {
 
                response = ex.Message;
 
            }
 
            finally
 
            {
 
                myWriter.Close();
 
            }
 
        }
 

        HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse();
 
        using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()))
 
        {
 
            response = sr.ReadToEnd();
 
            Response.Write(response);
 
            sr.Close(); // Close and clean up the StreamReader
 
        }
 
    }
 
}
 
get_user_course_events
using System;
 
using System.Collections;
 
using System.Configuration;
 
using System.Data;
 
using System.Linq;
 
using System.Web;
 
using System.Web.Security;
 
using System.Web.UI;
 
using System.Web.UI.HtmlControls;
 
using System.Web.UI.WebControls;
 
using System.Web.UI.WebControls.WebParts;
 
using System.Xml.Linq;
 
using System.IO;
 
using System.Text;
 
using System.Xml;
 
using System.Net;
 
using System.Diagnostics;
 

public partial class TestPage : System.Web.UI.Page
 
{
 
    protected void Page_Load(object sender, EventArgs e)
 
    {
 

    }
 

    protected void btnSubmit_Click(object sender, EventArgs e)
 
    {
 
        string url = "http://{sitename}/blocks/conduit/webservices/rest/user.php", token = "{token}", response = "", user = “james”;
 
        string field = "username", value = "guest", fromdata = "1291506600";
 

        string postData = "method=get_user_course_events&token=" + token + “field=”+user+ "value="+value+ "fromdata="+fromdata+"todate="+DateTime.Now.ToString();
 

        StreamWriter myWriter = null;
 
        HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url);
 
        objRequest.Method = "POST";
 
        objRequest.ContentType = "application/x-www-form-urlencoded";
 
        objRequest.ContentLength = postData.Length;
 

        if (sb.ToString() != "")
 
        {
 
            try
 
            {
 
                myWriter = new StreamWriter(objRequest.GetRequestStream());
 
                myWriter.Write(postData);
 
            }
 
            catch (Exception ex)
 
            {
 
                response = ex.Message;
 
            }
 
            finally
 
            {
 
                myWriter.Close();
 
            }
 
        }
 

        HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse();
 
        using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()))
 
        {
 
            response = sr.ReadToEnd();
 
            Response.Write(response);
 
            sr.Close(); // Close and clean up the StreamReader
 
        }
 
    }
 
}
 
get_user_grades
using System;
 
using System.Collections;
 
using System.Configuration;
 
using System.Data;
 
using System.Linq;
 
using System.Web;
 
using System.Web.Security;
 
using System.Web.UI;
 
using System.Web.UI.HtmlControls;
 
using System.Web.UI.WebControls;
 
using System.Web.UI.WebControls.WebParts;
 
using System.Xml.Linq;
 
using System.IO;
 
using System.Text;
 
using System.Xml;
 
using System.Net;
 
using System.Diagnostics;
 

public partial class TestPage : System.Web.UI.Page
 
{
 
    protected void Page_Load(object sender, EventArgs e)
 
    {
 

    }
 

    protected void btnSubmit_Click(object sender, EventArgs e)
 
    {
 
        string url = "http://{sitename}/blocks/conduit/webservices/rest/user.php", token = "{token}", response = "", user = “james”;
 

        string postData = "method=get_user_grades&token=" + token + “user=”+user;
 

        StreamWriter myWriter = null;
 
        HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url);
 
        objRequest.Method = "POST";
 
        objRequest.ContentType = "application/x-www-form-urlencoded";
 
        objRequest.ContentLength = postData.Length;
 

        if (sb.ToString() != "")
 
        {
 
            try
 
            {
 
                myWriter = new StreamWriter(objRequest.GetRequestStream());
 
                myWriter.Write(postData);
 
            }
 
            catch (Exception ex)
 
            {
 
                response = ex.Message;
 
            }
 
            finally
 
            {
 
                myWriter.Close();
 
            }
 
        }
 

        HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse();
 
        using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()))
 
        {
 
            response = sr.ReadToEnd();
 
            Response.Write(response);
 
            sr.Close(); // Close and clean up the StreamReader
 
        }
 
    }
 
}
 
Handle

The following are examples of handle file that you use to create records.

Action Create

using System;
 
using System.Collections;
 
using System.Configuration;
 
using System.Data;
 
using System.Linq;
 
using System.Web;
 
using System.Web.Security;
 
using System.Web.UI;
 
using System.Web.UI.HtmlControls;
 
using System.Web.UI.WebControls;
 
using System.Web.UI.WebControls.WebParts;
 
using System.Xml.Linq;
 
using System.IO;
 
using System.Text;
 
using System.Xml;
 
using System.Net;
 
using System.Diagnostics;
 

public partial class TestPage : System.Web.UI.Page
 
{
 
    protected void Page_Load(object sender, EventArgs e)
 
    {
 

    }
 

    protected void btnSubmit_Click(object sender, EventArgs e)
 
    {
 
        string url = "http://{sitename}/blocks/conduit/webservices/rest/user.php", token = "{token}", response = "";
 
        StringBuilder sb = new StringBuilder();
 

        sb.Append("<?xml version="1.0" encoding="UTF-8"?>");
 
        sb.Append("<data><datum action="create">");
 
        sb.Append("<mapping name="username">testuser</mapping>");
 
        sb.Append("<mapping name="password">testuser</mapping>");
 
        sb.Append("<mapping name="idnumber">Test10001</mapping>");
 
        sb.Append("<mapping name="firstname">Test</mapping>");
 
        sb.Append("<mapping name="lastname">User</mapping>");
 
        sb.Append("<mapping name="email">
 testuser@localhost.com
 </mapping>");
 
        sb.Append("<mapping name="phone1">(123) 456-7891</mapping>");
 
        sb.Append("<mapping name="phone2">(123) 456-7891</mapping>");
 
        sb.Append("<mapping name="address">1234 Some Street</mapping>");
 
        sb.Append("<mapping name="city">Baltimore</mapping>");
 
        sb.Append("<mapping name="country">US</mapping>");
 
        sb.Append("</datum> </data>");
 

        string postData = "method=handle&token=" + token + "&xml=" + Server.UrlEncode(sb.ToString());
 

        StreamWriter myWriter = null;
 
        HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url);
 
        objRequest.Method = "POST";
 
        objRequest.ContentType = "application/x-www-form-urlencoded";
 
        objRequest.ContentLength = postData.Length;
 

        if (sb.ToString() != "")
 
        {
 
            try
 
            {
 
                myWriter = new StreamWriter(objRequest.GetRequestStream());
 
                myWriter.Write(postData);
 
            }
 
            catch (Exception ex)
 
            {
 
                response = ex.Message;
 
            }
 
            finally
 
            {
 
                myWriter.Close();
 
            }
 
        }
 

        HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse();
 
        using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()))
 
        {
 
            response = sr.ReadToEnd();
 
            Response.Write(response);
 
            sr.Close(); // Close and clean up the StreamReader
 
        }
 
    }
 
}
 

Action Update

using System;
 
using System.Collections;
 
using System.Configuration;
 
using System.Data;
 
using System.Linq;
 
using System.Web;
 
using System.Web.Security;
 
using System.Web.UI;
 
using System.Web.UI.HtmlControls;
 
using System.Web.UI.WebControls;
 
using System.Web.UI.WebControls.WebParts;
 
using System.Xml.Linq;
 
using System.IO;
 
using System.Text;
 
using System.Xml;
 
using System.Net;
 
using System.Diagnostics;
 

public partial class TestPage : System.Web.UI.Page
 
{
 
    protected void Page_Load(object sender, EventArgs e)
 
    {
 

    }
 

    protected void btnSubmit_Click(object sender, EventArgs e)
 
    {
 
        string url = "http://{sitename}/blocks/conduit/webservices/rest/user.php", token = "{token}", response = "";
 
        StringBuilder sb = new StringBuilder();
 

        sb.Append("<?xml version="1.0" encoding="UTF-8"?>");
 
        sb.Append("<data><datum action="update">");
 
        sb.Append("<mapping name="username">testuser</mapping>");
 
        sb.Append("<mapping name="password">testuser</mapping>");
 
        sb.Append("<mapping name="idnumber">Test10001</mapping>");
 
        sb.Append("<mapping name="firstname">Test</mapping>");
 
        sb.Append("<mapping name="lastname">User</mapping>");
 
        sb.Append("<mapping name="email">
 testuser@localhost.com</mapping>");
        sb.Append("<mapping name="phone1">(123) 456-7891</mapping>");
 
        sb.Append("<mapping name="phone2">(123) 456-7891</mapping>");
 
        sb.Append("<mapping name="address">1234 Some Street</mapping>");
 
        sb.Append("<mapping name="city">Baltimore</mapping>");
 
        sb.Append("<mapping name="country">US</mapping>");
 
        sb.Append("</datum> </data>");
 

        string postData = "method=handle&token=" + token + "&xml=" + Server.UrlEncode(sb.ToString());
 

        StreamWriter myWriter = null;
 
        HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url);
 
        objRequest.Method = "POST";
 
        objRequest.ContentType = "application/x-www-form-urlencoded";
 
        objRequest.ContentLength = postData.Length;
 

        if (sb.ToString() != "")
 
        {
 
            try
 
            {
 
                myWriter = new StreamWriter(objRequest.GetRequestStream());
 
                myWriter.Write(postData);
 
            }
 
            catch (Exception ex)
 
            {
 
                response = ex.Message;
 
            }
 
            finally
 
            {
 
                myWriter.Close();
 
            }
 
        }
 

        HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse();
 
        using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()))
 
        {
 
            response = sr.ReadToEnd();
 
            Response.Write(response);
 
            sr.Close(); // Close and clean up the StreamReader
 
        }
 
    }
 
}
 

Action Delete

using System;
 
using System.Collections;
 
using System.Configuration;
 
using System.Data;
 
using System.Linq;
 
using System.Web;
 
using System.Web.Security;
 
using System.Web.UI;
 
using System.Web.UI.HtmlControls;
 
using System.Web.UI.WebControls;
 
using System.Web.UI.WebControls.WebParts;
 
using System.Xml.Linq;
 
using System.IO;
 
using System.Text;
 
using System.Xml;
 
using System.Net;
 
using System.Diagnostics;
 

public partial class TestPage : System.Web.UI.Page
 
{
 
    protected void Page_Load(object sender, EventArgs e)
 
    {
 

    }
 

    protected void btnSubmit_Click(object sender, EventArgs e)
 
    {
 
        string url = "http://{sitename}/blocks/conduit/webservices/rest/user.php", token = "{token}", response = "";
 
        StringBuilder sb = new StringBuilder();
 

        sb.Append("<?xml version="1.0" encoding="UTF-8"?>");
 
        sb.Append("<data><datum action="delete">");
 
        sb.Append("<mapping name="username">testuser</mapping>");
 
        sb.Append("</datum> </data>");
 

        string postData = "method=handle&token=" + token + "&xml=" + Server.UrlEncode(sb.ToString());
 

        StreamWriter myWriter = null;
 
        HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url);
 
        objRequest.Method = "POST";
 
        objRequest.ContentType = "application/x-www-form-urlencoded";
 
        objRequest.ContentLength = postData.Length;
 

        if (sb.ToString() != "")
 
        {
 
            try
 
            {
 
                myWriter = new StreamWriter(objRequest.GetRequestStream());
 
                myWriter.Write(postData);
 
            }
 
            catch (Exception ex)
 
            {
 
                response = ex.Message;
 
            }
 
            finally
 
            {
 
                myWriter.Close();
 
            }
 
        }
 

        HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse();
 
        using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()))
 
        {
 
            response = sr.ReadToEnd();
 
            Response.Write(response);
 
            sr.Close(); // Close and clean up the StreamReader
 
        }
 
    }
 
}
 

Course Web Service Examples

Methods

get_course
using System;
 
using System.Collections;
 
using System.Configuration;
 
using System.Data;
 
using System.Linq;
 
using System.Web;
 
using System.Web.Security;
 
using System.Web.UI;
 
using System.Web.UI.HtmlControls;
 
using System.Web.UI.WebControls;
 
using System.Web.UI.WebControls.WebParts;
 
using System.Xml.Linq;
 
using System.IO;
 
using System.Text;
 
using System.Xml;
 
using System.Net;
 
using System.Diagnostics;
 

public partial class TestPage : System.Web.UI.Page
 
{
 
    protected void Page_Load(object sender, EventArgs e)
 
    {
 

    }
 

    protected void btnSubmit_Click(object sender, EventArgs e)
 
    {
 
        string url = "http://{sitename}/blocks/conduit/webservices/rest/course.php", token = "{token}", response = "", value="CF101";
 

        string postData = "method=get_course&token=" + token+"value="+value;
 

        StreamWriter myWriter = null;
 
        HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url);
 
        objRequest.Method = "POST";
 
        objRequest.ContentType = "application/x-www-form-urlencoded";
 
        objRequest.ContentLength = postData.Length;
 

        if (sb.ToString() != "")
 
        {
 
            try
 
            {
 
                myWriter = new StreamWriter(objRequest.GetRequestStream());
 
                myWriter.Write(postData);
 
            }
 
            catch (Exception ex)
 
            {
 
                response = ex.Message;
 
            }
 
            finally
 
            {
 
                myWriter.Close();
 
            }
 
        }
 

        HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse();
 
        using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()))
 
        {
 
            response = sr.ReadToEnd();
 
            Response.Write(response);
 
            sr.Close(); // Close and clean up the StreamReader
 
        }
 
    }
 
}
 
get_course_grades
using System;
 
using System.Collections;
 
using System.Configuration;
 
using System.Data;
 
using System.Linq;
 
using System.Web;
 
using System.Web.Security;
 
using System.Web.UI;
 
using System.Web.UI.HtmlControls;
 
using System.Web.UI.WebControls;
 
using System.Web.UI.WebControls.WebParts;
 
using System.Xml.Linq;
 
using System.IO;
 
using System.Text;
 
using System.Xml;
 
using System.Net;
 
using System.Diagnostics;
 

public partial class TestPage : System.Web.UI.Page
 
{
 
    protected void Page_Load(object sender, EventArgs e)
 
    {
 

    }
 

    protected void btnSubmit_Click(object sender, EventArgs e)
 
    {
 
        string url = "http://{sitename}/blocks/conduit/webservices/rest/course.php", token = "{token}", response = "";
 

        string postData = "method=get_course_grades&token=" + token;
 

        StreamWriter myWriter = null;
 
        HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url);
 
        objRequest.Method = "POST";
 
        objRequest.ContentType = "application/x-www-form-urlencoded";
 
        objRequest.ContentLength = postData.Length;
 

        if (sb.ToString() != "")
 
        {
 
            try
 
            {
 
                myWriter = new StreamWriter(objRequest.GetRequestStream());
 
                myWriter.Write(postData);
 
            }
 
            catch (Exception ex)
 
            {
 
                response = ex.Message;
 
            }
 
            finally
 
            {
 
                myWriter.Close();
 
            }
 
        }
 

        HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse();
 
        using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()))
 
        {
 
            response = sr.ReadToEnd();
 
            Response.Write(response);
 
            sr.Close(); // Close and clean up the StreamReader
 
        }
 
    }
 
}
 
Handle

The following are examples of handle file that you use to create records.

Action Create

using System;
 
using System.Collections;
 
using System.Configuration;
 
using System.Data;
 
using System.Linq;
 
using System.Web;
 
using System.Web.Security;
 
using System.Web.UI;
 
using System.Web.UI.HtmlControls;
 
using System.Web.UI.WebControls;
 
using System.Web.UI.WebControls.WebParts;
 
using System.Xml.Linq;
 
using System.IO;
 
using System.Text;
 
using System.Xml;
 
using System.Net;
 
using System.Diagnostics;
 

public partial class TestPage : System.Web.UI.Page
 
{
 
    protected void Page_Load(object sender, EventArgs e)
 
    {
 

    }
 

    protected void btnSubmit_Click(object sender, EventArgs e)
 
    {
 
        string url = "http://{sitename}/blocks/conduit/webservices/rest/course.php", token = "{token}", response = "";
 
        StringBuilder sb = new StringBuilder();
 

        sb.Append("<?xml version="1.0" encoding="UTF-8"?>");
 
        sb.Append("<data><datum action="create">");
 
      sb.Append("<mapping name="shortname">testcourse</mapping>");
 
      sb.Append("<mapping name="fullname">Test Course</mapping>");
 
      sb.Append("<mapping name="idnumber">test</mapping>");
 
      sb.Append("<mapping name="summary">Web service test</mapping>");
 
      sb.Append("</datum> </data>");
 

        string postData = "method=handle&token=" + token + "&xml=" + Server.UrlEncode(sb.ToString());
 

        StreamWriter myWriter = null;
 
        HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url);
 
        objRequest.Method = "POST";
 
        objRequest.ContentType = "application/x-www-form-urlencoded";
 
        objRequest.ContentLength = postData.Length;
 

        if (sb.ToString() != "")
 
        {
 
            try
 
            {
 
                myWriter = new StreamWriter(objRequest.GetRequestStream());
 
                myWriter.Write(postData);
 
            }
 
            catch (Exception ex)
 
            {
 
                response = ex.Message;
 
            }
 
            finally
 
            {
 
                myWriter.Close();
 
            }
 
        }
 

        HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse();
 
        using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()))
 
        {
 
            response = sr.ReadToEnd();
 
            Response.Write(response);
 
            sr.Close(); // Close and clean up the StreamReader
 
        }
 
    }
 
}
 

Action Update

using System;
 
using System.Collections;
 
using System.Configuration;
 
using System.Data;
 
using System.Linq;
 
using System.Web;
 
using System.Web.Security;
 
using System.Web.UI;
 
using System.Web.UI.HtmlControls;
 
using System.Web.UI.WebControls;
 
using System.Web.UI.WebControls.WebParts;
 
using System.Xml.Linq;
 
using System.IO;
 
using System.Text;
 
using System.Xml;
 
using System.Net;
 
using System.Diagnostics;
 

public partial class TestPage : System.Web.UI.Page
 
{
 
    protected void Page_Load(object sender, EventArgs e)
 
    {
 

    }
 

    protected void btnSubmit_Click(object sender, EventArgs e)
 
    {
 
        string url = "http://{sitename}/blocks/conduit/webservices/rest/course.php", token = "{token}", response = "";
 
        StringBuilder sb = new StringBuilder();
 

        sb.Append("<?xml version="1.0" encoding="UTF-8"?>");
 
        sb.Append("<data><datum action="update">");
 
      sb.Append("<mapping name="shortname">testcourse</mapping>");
 
      sb.Append("<mapping name="fullname">Test Course</mapping>");
 
      sb.Append("<mapping name="idnumber">test</mapping>");
 
      sb.Append("<mapping name="summary">Web service test</mapping>");
 
      sb.Append("</datum> </data>");
 

        string postData = "method=handle&token=" + token + "&xml=" + Server.UrlEncode(sb.ToString());
 

        StreamWriter myWriter = null;
 
        HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url);
 
        objRequest.Method = "POST";
 
        objRequest.ContentType = "application/x-www-form-urlencoded";
 
        objRequest.ContentLength = postData.Length;
 

        if (sb.ToString() != "")
 
        {
 
            try
 
            {
 
                myWriter = new StreamWriter(objRequest.GetRequestStream());
 
                myWriter.Write(postData);
 
            }
 
            catch (Exception ex)
 
            {
 
                response = ex.Message;
 
            }
 
            finally
 
            {
 
                myWriter.Close();
 
            }
 
        }
 

        HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse();
 
        using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()))
 
        {
 
            response = sr.ReadToEnd();
 
            Response.Write(response);
 
            sr.Close(); // Close and clean up the StreamReader
 
        }
 
    }
 
}
 

Action Delete

using System;
 
using System.Collections;
 
using System.Configuration;
 
using System.Data;
 
using System.Linq;
 
using System.Web;
 
using System.Web.Security;
 
using System.Web.UI;
 
using System.Web.UI.HtmlControls;
 
using System.Web.UI.WebControls;
 
using System.Web.UI.WebControls.WebParts;
 
using System.Xml.Linq;
 
using System.IO;
 
using System.Text;
 
using System.Xml;
 
using System.Net;
 
using System.Diagnostics;
 

public partial class TestPage : System.Web.UI.Page
 
{
 
    protected void Page_Load(object sender, EventArgs e)
 
    {
 

    }
 

    protected void btnSubmit_Click(object sender, EventArgs e)
 
    {
 
        string url = "http://{sitename}/blocks/conduit/webservices/rest/course.php", token = "{token}", response = "";
 
        StringBuilder sb = new StringBuilder();
 

        sb.Append("<?xml version="1.0" encoding="UTF-8"?>");
 
        sb.Append("<data><datum action="delete">");
 
    sb.Append("<mapping name="shortname">testcourse</mapping>");
 
        sb.Append("</datum> </data>");
 

        string postData = "method=handle&token=" + token + "&xml=" + Server.UrlEncode(sb.ToString());
 

        StreamWriter myWriter = null;
 
        HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url);
 
        objRequest.Method = "POST";
 
        objRequest.ContentType = "application/x-www-form-urlencoded";
 
        objRequest.ContentLength = postData.Length;
 

        if (sb.ToString() != "")
 
        {
 
            try
 
            {
 
                myWriter = new StreamWriter(objRequest.GetRequestStream());
 
                myWriter.Write(postData);
 
            }
 
            catch (Exception ex)
 
            {
 
                response = ex.Message;
 
            }
 
            finally
 
            {
 
                myWriter.Close();
 
            }
 
        }
 

        HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse();
 
        using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()))
 
        {
 
            response = sr.ReadToEnd();
 
            Response.Write(response);
 
            sr.Close(); // Close and clean up the StreamReader
 
        }
 
    }
 
}
 

Enroll Web Service Examples

Handle

Action Create

using System;
 
using System.Collections;
 
using System.Configuration;
 
using System.Data;
 
using System.Linq;
 
using System.Web;
 
using System.Web.Security;
 
using System.Web.UI;
 
using System.Web.UI.HtmlControls;
 
using System.Web.UI.WebControls;
 
using System.Web.UI.WebControls.WebParts;
 
using System.Xml.Linq;
 
using System.IO;
 
using System.Text;
 
using System.Xml;
 
using System.Net;
 
using System.Diagnostics;
 

public partial class TestPage : System.Web.UI.Page
 
{
 
    protected void Page_Load(object sender, EventArgs e)
 
    {
 

    }
 

    protected void btnSubmit_Click(object sender, EventArgs e)
 
    {
 
        string url = "http://{sitename}/blocks/conduit/webservices/rest/enroll.php", token = "{token}", response = "";
 
        StringBuilder sb = new StringBuilder();
 

        sb.Append("<?xml version="1.0" encoding="UTF-8"?>");
 
        sb.Append("<data><datum action="create">");
 
    sb.Append(“<mapping name="coursekey">testcourse</mapping>");
 
    sb.Append(“<mapping name="userkey">testuser</mapping>");
 
    sb.Append(“<mapping name="rolekey">student</mapping>");
 
        sb.Append("</datum> </data>");
 

        string postData = "method=handle&token=" + token + "&xml=" + Server.UrlEncode(sb.ToString());
 

        StreamWriter myWriter = null;
 
        HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url);
 
        objRequest.Method = "POST";
 
        objRequest.ContentType = "application/x-www-form-urlencoded";
 
        objRequest.ContentLength = postData.Length;
 

        if (sb.ToString() != "")
 
        {
 
            try
 
            {
 
                myWriter = new StreamWriter(objRequest.GetRequestStream());
 
                myWriter.Write(postData);
 
            }
 
            catch (Exception ex)
 
            {
 
                response = ex.Message;
 
            }
 
            finally
 
            {
 
                myWriter.Close();
 
            }
 
        }
 

        HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse();
 
        using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()))
 
        {
 
            response = sr.ReadToEnd();
 
            Response.Write(response);
 
            sr.Close(); // Close and clean up the StreamReader
 
        }
 
    }
 
}
 

Action Update

using System;
 
using System.Collections;
 
using System.Configuration;
 
using System.Data;
 
using System.Linq;
 
using System.Web;
 
using System.Web.Security;
 
using System.Web.UI;
 
using System.Web.UI.HtmlControls;
 
using System.Web.UI.WebControls;
 
using System.Web.UI.WebControls.WebParts;
 
using System.Xml.Linq;
 
using System.IO;
 
using System.Text;
 
using System.Xml;
 
using System.Net;
 
using System.Diagnostics;
 

public partial class TestPage : System.Web.UI.Page
 
{
 
    protected void Page_Load(object sender, EventArgs e)
 
    {
 

    }
 

    protected void btnSubmit_Click(object sender, EventArgs e)
 
    {
 
        string url = "http://{sitename}/blocks/conduit/webservices/rest/enroll.php", token = "{token}", response = "";
 
        StringBuilder sb = new StringBuilder();
 

        sb.Append("<?xml version="1.0" encoding="UTF-8"?>");
 
        sb.Append("<data><datum action="update">");
 
        sb.Append("<mapping name="coursekey">testcourse</mapping>");
 
        sb.Append(“<mapping name="userkey">testuser</mapping>");
 
        sb.Append(“<mapping name="timestart">1296762421</mapping>");
 
        sb.Append(“<mapping name="timeend">1296760000</mapping>");
 
        sb.Append("</datum> </data>");
 

        string postData = "method=handle&token=" + token + "&xml=" + Server.UrlEncode(sb.ToString());
 

        StreamWriter myWriter = null;
 
        HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url);
 
        objRequest.Method = "POST";
 
        objRequest.ContentType = "application/x-www-form-urlencoded";
 
        objRequest.ContentLength = postData.Length;
 

        if (sb.ToString() != "")
 
        {
 
            try
 
            {
 
                myWriter = new StreamWriter(objRequest.GetRequestStream());
 
                myWriter.Write(postData);
 
            }
 
            catch (Exception ex)
 
            {
 
                response = ex.Message;
 
            }
 
            finally
 
            {
 
                myWriter.Close();
 
            }
 
        }
 

        HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse();
 
        using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()))
 
        {
 
            response = sr.ReadToEnd();
 
            Response.Write(response);
 
            sr.Close(); // Close and clean up the StreamReader
 
        }
 
    }
 
}
 

get_user_grades

using System;
 
using System.Collections;
 
using System.Configuration;
 
using System.Data;
 
using System.Linq;
 
using System.Web;
 
using System.Web.Security;
 
using System.Web.UI;
 
using System.Web.UI.HtmlControls;
 
using System.Web.UI.WebControls;
 
using System.Web.UI.WebControls.WebParts;
 
using System.Xml.Linq;
 
using System.IO;
 
using System.Text;
 
using System.Xml;
 
using System.Net;
 
using System.Diagnostics;
 

public partial class TestPage : System.Web.UI.Page
 
{
 
    protected void Page_Load(object sender, EventArgs e)
 
    {
 

    }
 

    protected void btnSubmit_Click(object sender, EventArgs e)
 
    {
 
        string url = "http://{sitename}/blocks/conduit/webservices/rest/enroll.php", token = "{token}", response = "";
 
        StringBuilder sb = new StringBuilder();
 

        sb.Append("<?xml version="1.0" encoding="UTF-8"?>");
 
        sb.Append("<data><datum action="delete">");
 
        sb.Append("<mapping name="coursekey">testcourse</mapping>");
 
        sb.Append(“<mapping name="userkey">testuser</mapping>");
 
        sb.Append("</datum> </data>");
 

        string postData = "method=handle&token=" + token + "&xml=" + Server.UrlEncode(sb.ToString());
 

        StreamWriter myWriter = null;
 
        HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url);
 
        objRequest.Method = "POST";
 
        objRequest.ContentType = "application/x-www-form-urlencoded";
 
        objRequest.ContentLength = postData.Length;
 

        if (sb.ToString() != "")
 
        {
 
            try
 
            {
 
                myWriter = new StreamWriter(objRequest.GetRequestStream());
 
                myWriter.Write(postData);
 
            }
 
            catch (Exception ex)
 
            {
 
                response = ex.Message;
 
            }
 
            finally
 
            {
 
                myWriter.Close();
 
            }
 
        }
 

        HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse();
 
        using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()))
 
        {
 
            response = sr.ReadToEnd();
 
            Response.Write(response);
 
            sr.Close(); // Close and clean up the StreamReader
 
        }
 
    }
 
}
 

Role Assignment Web Service Examples

Handle

Action Create

using System;
 
using System.Collections;
 
using System.Configuration;
 
using System.Data;
 
using System.Linq;
 
using System.Web;
 
using System.Web.Security;
 
using System.Web.UI;
 
using System.Web.UI.HtmlControls;
 
using System.Web.UI.WebControls;
 
using System.Web.UI.WebControls.WebParts;
 
using System.Xml.Linq;
 
using System.IO;
 
using System.Text;
 
using System.Xml;
 
using System.Net;
 
using System.Diagnostics;
 

public partial class TestPage : System.Web.UI.Page
 
{
 
    protected void Page_Load(object sender, EventArgs e)
 
    {
 

    }
 

    protected void btnSubmit_Click(object sender, EventArgs e)
 
    {
 
        string url = "http://{sitename}/blocks/conduit/webservices/rest/role_assign.php", token = "{token}", response = "";
 
        StringBuilder sb = new StringBuilder();
 

        sb.Append("<?xml version="1.0" encoding="UTF-8"?>");
 
        sb.Append("<data><datum action="create">");
 
        sb.Append(“<mapping name="context">user</mapping>");
 
        sb.Append(“<mapping name="moodlekey">testuser</mapping>");
 
        sb.Append(“<mapping name="userkey">parent</mapping>");
 
        sb.Append(“<mapping name="rolekey">manager</mapping>");
 
        sb.Append("</datum> </data>");
 

        string postData = "method=handle&token=" + token + "&xml=" + Server.UrlEncode(sb.ToString());
 

        StreamWriter myWriter = null;
 
        HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url);
 
        objRequest.Method = "POST";
 
        objRequest.ContentType = "application/x-www-form-urlencoded";
 
        objRequest.ContentLength = postData.Length;
 

        if (sb.ToString() != "")
 
        {
 
            try
 
            {
 
                myWriter = new StreamWriter(objRequest.GetRequestStream());
 
                myWriter.Write(postData);
 
            }
 
            catch (Exception ex)
 
            {
 
                response = ex.Message;
 
            }
 
            finally
 
            {
 
                myWriter.Close();
 
            }
 
        }
 

        HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse();
 
        using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()))
 
        {
 
            response = sr.ReadToEnd();
 
            Response.Write(response);
 
            sr.Close(); // Close and clean up the StreamReader
 
        }
 
    }
 
}
 

Action Update

using System;
 
using System.Collections;
 
using System.Configuration;
 
using System.Data;
 
using System.Linq;
 
using System.Web;
 
using System.Web.Security;
 
using System.Web.UI;
 
using System.Web.UI.HtmlControls;
 
using System.Web.UI.WebControls;
 
using System.Web.UI.WebControls.WebParts;
 
using System.Xml.Linq;
 
using System.IO;
 
using System.Text;
 
using System.Xml;
 
using System.Net;
 
using System.Diagnostics;
 

public partial class TestPage : System.Web.UI.Page
 
{
 
    protected void Page_Load(object sender, EventArgs e)
 
    {
 

    }
 

    protected void btnSubmit_Click(object sender, EventArgs e)
 
    {
 
        string url = "http://{sitename}/blocks/conduit/webservices/rest/role_assign.php", token = "{token}", response = "";
 
        StringBuilder sb = new StringBuilder();
 

        sb.Append("<?xml version="1.0" encoding="UTF-8"?>");
 
        sb.Append("<data><datum action="update">");
 
        sb.Append(“<mapping name="context">user</mapping>");
 
        sb.Append(“<mapping name="moodlekey">testuser</mapping>");
 
        sb.Append(“<mapping name="userkey">parent</mapping>");
 
        sb.Append(“<mapping name="rolekey">manager</mapping>");
 
        sb.Append(“<mapping name="timestart">1296762421</mapping>");
 
        sb.Append(“<mapping name="timeend">1296760000</mapping>");
 
        sb.Append("</datum> </data>");
 

        string postData = "method=handle&token=" + token + "&xml=" + Server.UrlEncode(sb.ToString());
 

        StreamWriter myWriter = null;
 
        HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url);
 
        objRequest.Method = "POST";
 
        objRequest.ContentType = "application/x-www-form-urlencoded";
 
        objRequest.ContentLength = postData.Length;
 

        if (sb.ToString() != "")
 
        {
 
            try
 
            {
 
                myWriter = new StreamWriter(objRequest.GetRequestStream());
 
                myWriter.Write(postData);
 
            }
 
            catch (Exception ex)
 
            {
 
                response = ex.Message;
 
            }
 
            finally
 
            {
 
                myWriter.Close();
 
            }
 
        }
 

        HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse();
 
        using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()))
 
        {
 
            response = sr.ReadToEnd();
 
            Response.Write(response);
 
            sr.Close(); // Close and clean up the StreamReader
 
        }
 
    }
 
}
 

Action Delete

using System;
 
using System.Collections;
 
using System.Configuration;
 
using System.Data;
 
using System.Linq;
 
using System.Web;
 
using System.Web.Security;
 
using System.Web.UI;
 
using System.Web.UI.HtmlControls;
 
using System.Web.UI.WebControls;
 
using System.Web.UI.WebControls.WebParts;
 
using System.Xml.Linq;
 
using System.IO;
 
using System.Text;
 
using System.Xml;
 
using System.Net;
 
using System.Diagnostics;
 

public partial class TestPage : System.Web.UI.Page
 
{
 
    protected void Page_Load(object sender, EventArgs e)
 
    {
 

    }
 

    protected void btnSubmit_Click(object sender, EventArgs e)
 
    {
 
        string url = "http://{sitename}/blocks/conduit/webservices/rest/role_assign.php", token = "{token}", response = "";
 
        StringBuilder sb = new StringBuilder();
 

        sb.Append("<?xml version="1.0" encoding="UTF-8"?>");
 
        sb.Append("<data><datum action="delete">");
 
        sb.Append(“<mapping name="context">user</mapping>");
 
        sb.Append(“<mapping name="moodlekey">testuser</mapping>");
 
        sb.Append(“<mapping name="userkey">parent</mapping>");
 
        sb.Append(“<mapping name="rolekey">manager</mapping>");
 
        sb.Append("</datum> </data>");
 

        string postData = "method=handle&token=" + token + "&xml=" + Server.UrlEncode(sb.ToString());
 

        StreamWriter myWriter = null;
 
        HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url);
 
        objRequest.Method = "POST";
 
        objRequest.ContentType = "application/x-www-form-urlencoded";
 
        objRequest.ContentLength = postData.Length;
 

        if (sb.ToString() != "")
 
        {
 
            try
 
            {
 
                myWriter = new StreamWriter(objRequest.GetRequestStream());
 
                myWriter.Write(postData);
 
            }
 
            catch (Exception ex)
 
            {
 
                response = ex.Message;
 
            }
 
            finally
 
            {
 
                myWriter.Close();
 
            }
 
        }
 

        HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse();
 
        using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()))
 
        {
 
            response = sr.ReadToEnd();
 
            Response.Write(response);
 
            sr.Close(); // Close and clean up the StreamReader
 
        }
 
    }
 
}
 

Groups Web Service Examples

Methods

get_groups
using System;
 
using System.Collections;
 
using System.Configuration;
 
using System.Data;
 
using System.Linq;
 
using System.Web;
 
using System.Web.Security;
 
using System.Web.UI;
 
using System.Web.UI.HtmlControls;
 
using System.Web.UI.WebControls;
 
using System.Web.UI.WebControls.WebParts;
 
using System.Xml.Linq;
 
using System.IO;
 
using System.Text;
 
using System.Xml;
 
using System.Net;
 
using System.Diagnostics;
 

public partial class TestPage : System.Web.UI.Page
 
{
 
    protected void Page_Load(object sender, EventArgs e)
 
    {
 

    }
 

    protected void btnSubmit_Click(object sender, EventArgs e)
 
    {
 
        string url = "http://{sitename}/blocks/conduit/webservices/rest/groups.php", token = "{token}", response = "";
 
        string shortname = "CF101";
 

        string postData = "method=get_groups&token=" + token + "shortname="+shortname;
 

        StreamWriter myWriter = null;
 
        HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url);
 
        objRequest.Method = "POST";
 
        objRequest.ContentType = "application/x-www-form-urlencoded";
 
        objRequest.ContentLength = postData.Length;
 

        if (sb.ToString() != "")
 
        {
 
            try
 
            {
 
                myWriter = new StreamWriter(objRequest.GetRequestStream());
 
                myWriter.Write(postData);
 
            }
 
            catch (Exception ex)
 
            {
 
                response = ex.Message;
 
            }
 
            finally
 
            {
 
                myWriter.Close();
 
            }
 
        }
 

        HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse();
 
        using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()))
 
        {
 
            response = sr.ReadToEnd();
 
            Response.Write(response);
 
            sr.Close(); // Close and clean up the StreamReader
 
        }
 
    }
 
}
 
Handle

Action Create

using System;
 
using System.Collections;
 
using System.Configuration;
 
using System.Data;
 
using System.Linq;
 
using System.Web;
 
using System.Web.Security;
 
using System.Web.UI;
 
using System.Web.UI.HtmlControls;
 
using System.Web.UI.WebControls;
 
using System.Web.UI.WebControls.WebParts;
 
using System.Xml.Linq;
 
using System.IO;
 
using System.Text;
 
using System.Xml;
 
using System.Net;
 
using System.Diagnostics;
 

public partial class TestPage : System.Web.UI.Page
 
{
 
    protected void Page_Load(object sender, EventArgs e)
 
    {
 

    }
 

    protected void btnSubmit_Click(object sender, EventArgs e)
 
    {
 
        string url = "http://{sitename}/blocks/conduit/webservices/rest/groups.php", token = "{token}", response = "";
 
        StringBuilder sb = new StringBuilder();
 

        sb.Append("<?xml version="1.0" encoding="UTF-8"?>");
 
        sb.Append("<data><datum action="create">");
 
        sb.Append("<mapping name="coursekey">testcourse</mapping>");
 
        sb.Append("<mapping name="groupkey">testgroup</mapping>");
 
        sb.Append("<mapping name="description">This is a test Conduit group</mapping>");
 
        sb.Append("</datum> </data>");
 

        string postData = "method=handle&token=" + token + "&xml=" + Server.UrlEncode(sb.ToString());
 

        StreamWriter myWriter = null;
 
        HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url);
 
        objRequest.Method = "POST";
 
        objRequest.ContentType = "application/x-www-form-urlencoded";
 
        objRequest.ContentLength = postData.Length;
 

        if (sb.ToString() != "")
 
        {
 
            try
 
            {
 
                myWriter = new StreamWriter(objRequest.GetRequestStream());
 
                myWriter.Write(postData);
 
            }
 
            catch (Exception ex)
 
            {
 
                response = ex.Message;
 
            }
 
            finally
 
            {
 
                myWriter.Close();
 
            }
 
        }
 

        HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse();
 
        using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()))
 
        {
 
            response = sr.ReadToEnd();
 
            Response.Write(response);
 
            sr.Close(); // Close and clean up the StreamReader
 
        }
 
    }
 
}
 

Action Update

01 using System;
 
02 using System.Collections;
 
03 using System.Configuration;
 
04 using System.Data;
 
05 using System.Linq;
 
06 using System.Web;
 
07 using System.Web.Security;
 
08 using System.Web.UI;
 
09 using System.Web.UI.HtmlControls;
 
10 using System.Web.UI.WebControls;
 
11 using System.Web.UI.WebControls.WebParts;
 
12 using System.Xml.Linq;
 
13 using System.IO;
 
14 using System.Text;
 
15 using System.Xml;
 
16 using System.Net;
 
17 using System.Diagnostics;
 
18
 
19 public partial class TestPage : System.Web.UI.Page
 
20 {
 
21     protected void Page_Load(object sender, EventArgs e)
 
22     {
 
23
 
24     }
 
25
 
26     protected void btnSubmit_Click(object sender, EventArgs e)
 
27     {
 
28         string url = "http://{sitename}/blocks/conduit/webservices/rest/groups.php", token = "{token}", response = "";
 
29         StringBuilder sb = new StringBuilder();
 
30
 
31         sb.Append("<?xml version="1.0" encoding="UTF-8"?>");
 
32         sb.Append("<data><datum action="update">");
 
33         sb.Append("<mapping name="coursekey">testcourse</mapping>");
 
34         sb.Append("<mapping name="groupkey">testgroup</mapping>");
 
35         sb.Append("<mapping name="newgroupkey">testgroup2</mapping>");
 
36         sb.Append("<mapping name="description">This is a test Conduit group</mapping>");
 
37         sb.Append("</datum> </data>");
 
38
 
39         string postData = "method=handle&token=" + token + "&xml=" + Server.UrlEncode(sb.ToString());
 
40
 
41         StreamWriter myWriter = null;
 
42         HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url);
 
43         objRequest.Method = "POST";
 
44         objRequest.ContentType = "application/x-www-form-urlencoded";
 
45         objRequest.ContentLength = postData.Length;
 
46
 
47         if (sb.ToString() != "")
 
48         {
 
49             try
 
50             {
 
51                 myWriter = new StreamWriter(objRequest.GetRequestStream());
 
52                 myWriter.Write(postData);
 
53             }
 
54             catch (Exception ex)
 
55             {
 
56                 response = ex.Message;
 
57             }
 
58             finally
 
59             {
 
60                 myWriter.Close();
 
61             }
 
62         }
 
63
 
64         HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse();
 
65         using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()))
 
66         {
 
67             response = sr.ReadToEnd();
 
68             Response.Write(response);
 
69             sr.Close(); // Close and clean up the StreamReader
 
70         }
 
71     }
 
72 }
 

Action Delete

using System;
 
using System.Collections;
 
using System.Configuration;
 
using System.Data;
 
using System.Linq;
 
using System.Web;
 
using System.Web.Security;
 
using System.Web.UI;
 
using System.Web.UI.HtmlControls;
 
using System.Web.UI.WebControls;
 
using System.Web.UI.WebControls.WebParts;
 
using System.Xml.Linq;
 
using System.IO;
 
using System.Text;
 
using System.Xml;
 
using System.Net;
 
using System.Diagnostics;
 

public partial class TestPage : System.Web.UI.Page
 
{
 
    protected void Page_Load(object sender, EventArgs e)
 
    {
 

    }
 

    protected void btnSubmit_Click(object sender, EventArgs e)
 
    {
 
        string url = "http://{sitename}/blocks/conduit/webservices/rest/groups.php", token = "{token}", response = "";
 
        StringBuilder sb = new StringBuilder();
 

        sb.Append("<?xml version="1.0" encoding="UTF-8"?>");
 
        sb.Append("<data><datum action="delete">");
 
        sb.Append("<mapping name="coursekey">testcourse</mapping>");
 
        sb.Append("<mapping name="groupkey">testgroup</mapping>");
 
        sb.Append("</datum> </data>");
 

        string postData = "method=handle&token=" + token + "&xml=" + Server.UrlEncode(sb.ToString());
 

        StreamWriter myWriter = null;
 
        HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url);
 
        objRequest.Method = "POST";
 
        objRequest.ContentType = "application/x-www-form-urlencoded";
 
        objRequest.ContentLength = postData.Length;
 

        if (sb.ToString() != "")
 
        {
 
            try
 
            {
 
                myWriter = new StreamWriter(objRequest.GetRequestStream());
 
                myWriter.Write(postData);
 
            }
 
            catch (Exception ex)
 
            {
 
                response = ex.Message;
 
            }
 
            finally
 
            {
 
                myWriter.Close();
 
            }
 
        }
 

        HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse();
 
        using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()))
 
        {
 
            response = sr.ReadToEnd();
 
            Response.Write(response);
 
            sr.Close(); // Close and clean up the StreamReader
 
        }
 
    }
 
}
 

Group Members Web Service Examples

Handle

Action Create


using System;
 
using System.Collections;
 
using System.Configuration;
 
using System.Data;
 
using System.Linq;
 
using System.Web;
 
using System.Web.Security;
 
using System.Web.UI;
 
using System.Web.UI.HtmlControls;
 
using System.Web.UI.WebControls;
 
using System.Web.UI.WebControls.WebParts;
 
using System.Xml.Linq;
 
using System.IO;
 
using System.Text;
 
using System.Xml;
 
using System.Net;
 
using System.Diagnostics;
 

public partial class TestPage : System.Web.UI.Page
 
{
 
    protected void Page_Load(object sender, EventArgs e)
 
    {
 

    }
 

    protected void btnSubmit_Click(object sender, EventArgs e)
 
    {
 
        string url = "http://{sitename}/blocks/conduit/webservices/rest/groups_members.php", token = "{token}", response = "";
 
        StringBuilder sb = new StringBuilder();
 

        sb.Append("<?xml version="1.0" encoding="UTF-8"?>");
 
        sb.Append("<data><datum action="create">");
 
        sb.Append("<mapping name="coursekey">testcourse</mapping>");
 
        sb.Append("<mapping name="userkey">testuser</mapping>");
 
        sb.Append("<mapping name="groupkey">testgroup</mapping>");
 
        sb.Append("</datum> </data>");
 

        string postData = "method=handle&token=" + token + "&xml=" + Server.UrlEncode(sb.ToString());
 

        StreamWriter myWriter = null;
 
        HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url);
 
        objRequest.Method = "POST";
 
        objRequest.ContentType = "application/x-www-form-urlencoded";
 
        objRequest.ContentLength = postData.Length;
 

        if (sb.ToString() != "")
 
        {
 
            try
 
            {
 
                myWriter = new StreamWriter(objRequest.GetRequestStream());
 
                myWriter.Write(postData);
 
            }
 
            catch (Exception ex)
 
            {
 
                response = ex.Message;
 
            }
 
            finally
 
            {
 
                myWriter.Close();
 
            }
 
        }
 

        HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse();
 
        using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()))
 
        {
 
            response = sr.ReadToEnd();
 
            Response.Write(response);
 
            sr.Close(); // Close and clean up the StreamReader
 
        }
 
    }
 
}
 

Action Delete

using System;
 
using System.Collections;
 
using System.Configuration;
 
using System.Data;
 
using System.Linq;
 
using System.Web;
 
using System.Web.Security;
 
using System.Web.UI;
 
using System.Web.UI.HtmlControls;
 
using System.Web.UI.WebControls;
 
using System.Web.UI.WebControls.WebParts;
 
using System.Xml.Linq;
 
using System.IO;
 
using System.Text;
 
using System.Xml;
 
using System.Net;
 
using System.Diagnostics;
 

public partial class TestPage : System.Web.UI.Page
 
{
 
    protected void Page_Load(object sender, EventArgs e)
 
    {
 

    }
 

    protected void btnSubmit_Click(object sender, EventArgs e)
 
    {
 
        string url = "http://{sitename}/blocks/conduit/webservices/rest/groups_members.php", token = "{token}", response = "";
 
        StringBuilder sb = new StringBuilder();
 

        sb.Append("<?xml version="1.0" encoding="UTF-8"?>");
 
        sb.Append("<data><datum action="delete">");
 
        sb.Append("<mapping name="coursekey">testcourse</mapping>");
 
        sb.Append("<mapping name="userkey">testuser</mapping>");
 
        sb.Append("<mapping name="groupkey">testgroup</mapping>");
 
        sb.Append("</datum> </data>");
 

        string postData = "method=handle&token=" + token + "&xml=" + Server.UrlEncode(sb.ToString());
 

        StreamWriter myWriter = null;
 
        HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url);
 
        objRequest.Method = "POST";
 
        objRequest.ContentType = "application/x-www-form-urlencoded";
 
        objRequest.ContentLength = postData.Length;
 

        if (sb.ToString() != "")
 
        {
 
            try
 
            {
 
                myWriter = new StreamWriter(objRequest.GetRequestStream());
 
                myWriter.Write(postData);
 
            }
 
            catch (Exception ex)
 
            {
                response = ex.Message;
            }
            finally
            {
                myWriter.Close();
            }
        }

        HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse();
        using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()))
        {
            response = sr.ReadToEnd();
            Response.Write(response);
            sr.Close(); // Close and clean up the StreamReader
        }
    }
}