AnsweredAssumed Answered

PHP / GuzzleHttp Post - new user creation

Question asked by Jeremiah Ellington on Jun 14, 2018
Latest reply on Jun 15, 2018 by Jeremiah Ellington

Hello,

 

I'm new to Canvas and attempting to create a new user through the Canvas API. I'm using PHP & GuzzleHttp to form the requests and getting the following error:

 

Client error: `POST https://mydomain.instructure.com/api/v1/accounts/1/users/?access_token=my_token` resulted in a `400 Bad Request` response: {"errors":{"user":{"pseudonyms":[{"attribute":"pseudonyms","type":"invalid","message":"invalid"}]},"pseudonym":{"unique_ (truncated...)

 

I'm setting the URL:

$url = "https://mydomain.instructure.com/api/v1/accounts/1/users/?$access_token";

 

I'm setting the Content-Type in the header of the Request:

headers = [
                'Content-Type' => 'application/json; charset=utf-8',
                'Accept' => 'application/json',
                ];

 

I'm using the below data in the body of the Post Request:

{"user":{"name":"Mary Alvarez Nutting","sortable_name":"Alvarez Nutting Mary"},"pseudonym":{"unique_id":"Mary_AlvarezNutting","sis_user_id":"1033587"}

 

 

and finally here is the Guzzle command i'm using:

$response = $client->post($url, $headers, $parm)->send();

 

Any help at all would be greatly appreciated!!

 

If any does look at this, Please let me know if I can provide anymore information that would help you help me!!!

 

Thank you,

Jeremiah

Outcomes