Exciting News!

Our transition to a new website is complete. Click here to seamlessly access the latest version of this article.

Kindly update any bookmarked URLs accordingly. The Development Center will no longer be accessible after April 1, 2024. Thank you for your attention to this matter.



Click here to go to GitHub


Insert the OneRoster folder into your project.


First, import the OneRoster package.

import ("../OneRoster")

Next, create a new instance of the OneRoster object, which takes in two strings,
the client_id and client_secret.


You are now able to make requests to a specified URL. This is done using the method MakeRosterRequest(url), which takes in the URL and returns the status code and response.

statusCode: response := oneRoster.MakeRosterRequest("https://example.com/users");

statusCode is an int containing the status code and response is a string with the JSON response.

fmt.Println(statusCode)  // The status code
fmt.Println(response)  // The JSON Response




Print all students' names

package main

// Import OneRoster
import (

type User struct {
	GivenName string
	FamilyName string

type UserResponse struct {
	Users []User

func getUsers(url string) []User {
	// Create new OneRoster with the client_id and client_secret

	// Make the request to the given url and store the status code and response
	statusCode, response := oneRoster.MakeRosterRequest(url)
	b := []byte(response)

	// If status_code is 200, create array of users from response, otherwise print message and return nil
	if statusCode == 200 {
		var userResponse = new(UserResponse)
		json.Unmarshal(b, &userResponse)
		return userResponse.Users
	if statusCode == 401 {
		fmt.Println("Unauthorized Request\n" + response)
	} else if statusCode == 404 {
		fmt.Println("Not found\n" + response)
	} else if statusCode == 500 {
		fmt.Println("Server Error\n" + response)
	} else  {
		fmt.Println("Something Went Wrong, status code " + fmt.Sprint(statusCode) + "\n" + response)

	return nil

// Print the users if not nil
func main() {
	users := getUsers("https://example.com/users?fields=givenName%2CfamilyName&filter=role%3D'student'")
	if users != nil {
		for _, user := range users {
			fmt.Println(user.GivenName + " " + user.FamilyName)