Celebrate Excellence in Education: Nominate Outstanding Educators by April 15!
Found this content helpful? Log in or sign up to leave a like!
Using the API we're having no problems at all creating students, enrolling them and fetching completions.
However, when changing a student from suspended to unsuspended (PUT action) I get the following error:
{"status":"unauthorized","errors":[{"message":"user not authorised to perform that action"}]}
The request is a PUT with an ContentType of "application/json" as follows:
{"user": { "suspend": false } }
Any hint on what we could be missing here?
For reference our (Java) code is as follows:
...
httpClient = HttpClientBuilder.create().build();
HttpPut putRequest = new HttpPut(base_u + query);
putRequest.addHeader("Authorization", "Bearer " + api_k);
StringEntity entity = new StringEntity(payload);
entity.setContentType("application/json");
putRequest.setEntity(entity);
response = httpClient.execute(putRequest);
HttpEntity resp_entity = response.getEntity();
String responseString = EntityUtils.toString(resp_entity, "UTF-8");
log(responseString);
...
It looks like the Edit a User endpoint is what you need for this. According to the documentation, the request parameter you would need to use is "user[event]" with a value of "suspend" or "unsuspend"
Have you tried using the following JSON for your request parameter?
{"user": {"event": "suspend"}}
Thank you James, much appreciated.
I misinterpreted the documentation. I was using the correct endpoint however was using the wrong syntax since the event is a string. Trying out your recommendation and will let you know the outcome.
Cheers, Pedro
To participate in the Instructure Community, you need to sign up or log in:
Sign In