Enrollment API via Postman
- Cy Jones (Deactivated)
- Ian Christopher (Deactivated)
Prerequisites
Before using this collection, follow the steps from Setting Up Postman.
Using the Collection
Select an Environment
In the top right corner, select an environment from the imported ones:
Click on the "Environments" tab and click on the Checkbox for the desired environment:
Authorization
In order to authenticate, an environment must be selected. The environment files includes a Key and Secret value for testing purposes.
In the "Collections" tab, click on the Ed-Fi Roster root folder, when the folder opens, select the "Authorization" tab.
Scroll down and click Get New Access Token.
The following confirmation message will appear:
Click on Use Token:
The token is ready to be used.
This token expires, therefore, this process must be repeated each time the token has expired.
All API calls inherit from this authorization token.
Execute the API Calls
There are two types of API calls, independent and dependent calls.
Independent API calls
These API calls can be executed directly once the token is generated, because it does not depend on any value to be executed.
To execute any of these API calls, select the call and click on Send. There's no modification needed, and if so, it means there's an error with the Authentication Token (in which case, it is better to follow the Authorization steps again).
After the request is done, the status 200 OK must appear and the Response body must be visible.
Dependent API calls
These API calls require a value in a variable in order to be executed. Those appear with the preposition 'by' in the API calls
There are two ways to get the variables needed for these API calls, this will be exemplified using the 'Schools by LEA' API call:
Copy and enter the ID required in the environment variables
Execute the "Local Education Agencies" API call
Copy the first ID in the result.
Go to the "Environments" tab and paste the copied value in the "Current Value" field for the lea_id variable:
Return to the Collection and execute the API call 'Schools by LEA'. Status 200 OK should appear and the Response body must be visible
Here, The lea_id variable is replaced with the value set.
If no value is set, the following error will appear:
Execute an API call that automatically sets the required variable
The API calls that are located under the "Enrollment Composite" folder that have the name "All" in it, will automatically set the value for the corresponding variable by setting the first result returned by the call.
For example, if you want to execute the 'Schools by LEA' API call, you can execute the 'All Local Education Agencies' API call first and that way the LEA variable will be automatically set and ready to use.
API Request | Request to set the variable |
---|---|
by LEA | "All Local Education Agencies" |
by School | "All Schools" |
by Staff | "All Staff" |
by Section | "All Sections" |
Getting Code Samples
Postman provides built in code samples for multiple programming languages per API request.
To get these code samples:
Open an API request and verify it's valid:
Click on the Code button on the right side menu ( ):
Select your programming language of choice in the dropdown and copy the code:
Code Samples
In order to run the samples, get a new Access Token and place it after the Bearer
import requests url = "https://api.ed-fi.org/v3.4.0/api/data/v3/ed-fi/staffs" payload={} headers = { 'Authorization': 'Bearer {{YourToken}}' } response = requests.request("GET", url, headers=headers, data=payload) print(response.text)
Demo:
var myHeaders = new Headers(); myHeaders.append("Authorization", "Bearer {{YourToken}}"); var requestOptions = { method: 'GET', headers: myHeaders, redirect: 'follow' }; fetch("https://api.ed-fi.org/v3.4.0/api/composites/v1/ed-fi/enrollment/staff", requestOptions) .then(response => response.text()) .then(result => console.log(result)) .catch(error => console.log('error', error));
Demo:
To execute this code, this snippet needs to be placed in a function and add the OkHttp dependency and import the following packages:
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
Also, the Java sample in Postman doesn't print the result, therefore this should also be included to see the result.
OkHttpClient client = new OkHttpClient().newBuilder() .build(); Request request = new Request.Builder() .url("https://api.ed-fi.org/v3.4.0/api/data/v3/ed-fi/staffs") .method("GET", null) .addHeader("Authorization", "Bearer {{YourToken}}") .build(); Response response = client.newCall(request).execute(); System.out.print(response.body().string());
require "uri" require "net/http" url = URI("https://api.ed-fi.org/v3.4.0/api/data/v3/ed-fi/staffs") https = Net::HTTP.new(url.host, url.port) https.use_ssl = true request = Net::HTTP::Get.new(url) request["Authorization"] = "Bearer {{YourToken}}" response = https.request(request) puts response.read_body
To execute this code, this snippet needs to be placed in a function and add the RestSharp dependency:
using RestSharp;
var client = new RestClient("https://api.ed-fi.org/v3.4.0/api/composites/v1/ed-fi/enrollment/staff"); client.Timeout = -1; var request = new RestRequest(Method.GET); request.AddHeader("Authorization", "Bearer {{YourToken}}"); IRestResponse response = client.Execute(request); Console.WriteLine(response.Content);
On this page: