I'm new to the Valence API and D2L(Brightspace) and I'm currently having issues with sending API Requests through my WordPress Enrollment form. Below are some steps as to what I am trying to achieve:
- A Student Signs up/enrolls in a course through an enrollment form on my WordPress site
- The enrollment passes the new student information to the Valence API doAPIRequest function in sample.js
- The Ajax call in sample.js contains an action called 'example_wordpress_action' which is defined in functions.php. This is where the API requests are made.
- The main problem is that when I try to use a post request, there is always a 400 Bad Request returned. However, I am able to apply a GET/ whoami request with out any issues. Is there a chance that the issues are with the way the user information is being entered?
Below is a copy of the format that is being used to send the created users information (The RoldId is being used on the D2L site and I am using method 'POST' and API request of '/d2l/api/lp/1.4/users/'):
{
"OrgDefinedId": "SBoateng",
"FirstName": "Samuel",
"MiddleName": "",
"LastName": "Boateng",
"ExternalEmail": "daerdocta@gmail.com",
"UserName": "SBoateng",
"RoleId": 103,
"IsActive": true,
"SendCreationEmail": false
}
This is what is returned from the request:
Unexpected non-JSON response from the server:
Array
(
[headers] => Array
(
[cache-control] => private
[content-length] => 0
[server] => Microsoft-IIS/7.5
[x-powered-by] => ASP.NET
[x-xss-protection] => 0
[date] => Tue, 23 Jun 2015 18:35:05 GMT
[connection] => close
)
[body] =>
[response] => Array
(
[code] => 400
[message] => Bad request
)
[cookies] => Array
(
)
[filename] =>
)