In this exercise, you will be integrating with the Ed-Fi ODS / API via an SDK instead of using Swagger UI. The Swagger UI serves as a very useful set of documentation and simple test bed, but the majority of your work with the Ed-Fi ODS / API will be via a programmatic integration.

Setup the labs

Download the lab solution from the following link. Open the solution in a separate instance of Visual Studio.

Note: The source code is already setup with the Ed-Fi SDK NuGet and sample code to access the Ed-Fi  hosted ODS / API instance via SDK. If you are setting up a new project follow these steps to download the Ed-Fi SDK NuGet :

Downloads



1.Open up Visual Studio and create a new project. Choose the type Visual C# > ClassLibrary. Name the project "EdfiBootCamp2017_SdkSample".


2.Go to Tools  > NuGet Package Manager  >  Package Manager Settings .


3. Add Ed-Fi NuGet feed to package sources: https://www.myget.org/F/ed-fi/

4.Right click on project > Manage NuGet Packages


5. Choose 'Ed-Fi Alliance NuGet Feed' Package Source and Install EdFi.OdsApi.Sdk  NuGet. Notice the dependency on RestSharp package


6. View EdFi.OdsApi.Sdk in Object Browser to see the namespaces and types in the SDK. You can see that SDK types are mainly grouped under the Apis, Models, and Helpers namespaces

Using the SDK

Using downloaded source code, you will be able to see the impact of the student school association as it relates to the ability to access the student.

Open the app.config file for the EdfiBootCamp2017_SdkSample project. Notice the configuration elements namely ODS / API base URL, key, secret for your populated template.

Open RestClientInitializer.cs file. Notice that it creates RestClient instance using the configuration settings to know how to connect to your target ODS / API instance. Once configured, RestClient auto-magically handles the oAuth handshake for you. 

Open IdGenerator.cs. This class is provided for for you to create a test unique ID for students.

Open StudentsSdkTests.cs  file. Notice the commented regions of code to call the API via SDK. Uncomment the regions one by one on each test until both tests pass. Notice the response code returned and the places where 403 is returned.

Note: You can use Swagger to determine which fields are required to create a Student/Student-School Association so that you can leave off any unnecessary fields when creating them.

This shows the impact of the StudentSchoolAssociation as it controls access to the student and the student’s related data for this claim set. The same is true for staff members and their relationship to the StaffEducationOrganizationEmploymentAssociation and the StaffEducationOrganizationAssignmentAssociation. Access to Parent information is restricted by the accessible Students and their StudentParentAssociations. For example, if “Student A” was accessible then any Parents to which he has a StudentParentAssociation would be accessible as well.

In this lab, you have seen use of the school year as it was used on the end of the base Url for the RestClient. You also see the school year in the Swagger calls. This used to tell the Ed-Fi ODS API which version of the ODS to use. In the sandbox environment, this does not have any impact since the connection to the database is decided based on the API key. In a production environment, the school year on the route may be the determining factor to find the correct database. 

  • No labels