Regent API Code Examples

Further examples showing how to interact with Student, Award and Documents. This is meant as an addendum to the main document found here: Regent Award .Net API User Guide

(info) Note: The examples below make use of the generic 'Student Portal' username and do not use a ClientId and Token. This is because the code below is example only. In practice the SecurityToken object should use a ClientId and Token as shown in the Regent Award .Net API User Guide. These two data attributes are provided by Regent after the client request to provision the web service end point is received. 


Get Student External Id by Student Id
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using YourServiceReferenceHere;


public SecurityToken GetAuth()
{
    SecurityToken securityToken = new SecurityToken()
    {
        Username = "Student Portal",
        UserId = -2,
        DashboardAdmin = true
    };

    return securityToken;
}

public async Task<long> GetStudentIdAsync()
{
    long studentid = -1;


    string externalId1 = "63650";
    GetStudentsRequest getStudentsRequest = new GetStudentsRequest();
    getStudentsRequest.SecurityToken = GetAuth();
    RegentEnterpriseServiceClient client = new RegentEnterpriseServiceClient();
    client.Endpoint.Address = new System.ServiceModel.EndpointAddress("http://regentremwsqa9.regenteducation.local/RegentEnterpriseWebService.svc");


    // this method is special in that you can build a dynamic set of filters. Here we want to find student internal Id
    getStudentsRequest.filter = new Filter
    {
        Filters = new List<Filter>
        {
            new Filter {Field = "externalId1", Operator = "eq", Value = externalId1}
        }.ToArray()
    };
    // here you cann add the additional conditions as sorting and the number of returning rows
    getStudentsRequest.sortColumn = null;
    getStudentsRequest.sortExpression = null;
    getStudentsRequest.startRowIndex = 1; // start and end row indexes are required to provide
    getStudentsRequest.endRowIndex = 1;
    
    getStudentsResponse = await client.getStudentBasicInfoListAsync(getStudentsRequest);

    if (!getStudentsResponse.Success)
        throw new ApplicationException(string.Format("Error calling {0}:{1}", "getStudentBasicInfoListAsync", getStudentsResponse.Message));

    // expect you'll get 1 and only 1 record. Adjust for your needs.
    if (getStudentsResponse.Records.Length != 1)
    {
        throw new ApplicationException(string.Format("Expected 1 student record but found {0} records", 0));
    }

    studentid = getStudentsResponse.Records[0].Id;
    return studentid;
}
Get Document Name by Student External Id
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using YourServiceReferenceHere;


public SecurityToken GetAuth()
{
    SecurityToken securityToken = new SecurityToken()
    {
        Username = "Student Portal",
        UserId = -2,
        DashboardAdmin = true
    };

    return securityToken;
}

 async Task<string> GetStudentDocument()
{
    string documentName = "";


    string externalId1 = "63650";
    GetStudentDocumentsLoadStudentListRequest getStudentDocumentsRequest = new GetStudentDocumentsLoadStudentListRequest();
    getStudentDocumentsRequest.SecurityToken = GetAuth();
    RegentEnterpriseServiceClient client = new RegentEnterpriseServiceClient();
    client.Endpoint.Address = new System.ServiceModel.EndpointAddress("http://regentremwsqa9.regenteducation.local/RegentEnterpriseWebService.svc");

    // here you cann add the different conditions as sorting and the number of returning rows
    getStudentDocumentsRequest.IOProcessId = 30; // required
    getStudentDocumentsRequest.sortColumn = null;
    getStudentDocumentsRequest.sortType = null;
    getStudentDocumentsRequest.filterCondition = "ExternalId1 = " + externalId1; // here you can provide filtering conditions
    getStudentDocumentsRequest.startRowIndex = 1; // start and end row indexes are required to provide
    getStudentDocumentsRequest.endRowIndex = 1;


    GetStudentDocumentsLoadStudentListResponse getStudentsDocumentsResponse = await client.getStudentDocumentsLoadStudentListAsync(getStudentDocumentsRequest);

    if (!getStudentsDocumentsResponse.Success)
        throw new ApplicationException(string.Format("Error calling {0}:{1}", "getStudentDocumentsLoadStudentListAsync", getStudentsDocumentsResponse.Message));
    

    documentName = getStudentsDocumentsResponse.Records[0].DocumentName;
    return documentName;
}
Get Task Description by Student Id
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using YourServiceReferenceHere;


public SecurityToken GetAuth()
{
    SecurityToken securityToken = new SecurityToken()
    {
        Username = "Student Portal",
        UserId = -2,
        DashboardAdmin = true
    };

    return securityToken;
}

public async Task<string> GetStudentTask()
{
    string taskDescription = "";


    long studentId = 11313;
    GetStudentTaskListRequest getStudentTaskRequest = new GetStudentTaskListRequest();
    getStudentTaskRequest.SecurityToken = GetAuth();
    RegentEnterpriseServiceClient client = new RegentEnterpriseServiceClient();
    client.Endpoint.Address = new System.ServiceModel.EndpointAddress("http://regentremwsqa9.regenteducation.local/RegentEnterpriseWebService.svc");

    // here you cann add the different conditions as sorting and the number of returning rows
    getStudentTaskRequest.StudentId = studentId; // required
    getStudentTaskRequest.sortColumn = null;
    getStudentTaskRequest.sortType = null;
    getStudentTaskRequest.startRowIndex = 1; // start and end row indexes are required to provide
    getStudentTaskRequest.endRowIndex = 1;


    GetStudentTaskListResponse getStudentsTaskResponse = await client.getStudentTaskListAsync(getStudentTaskRequest);

    if (!getStudentsTaskResponse.Success)
        throw new ApplicationException(string.Format("Error calling {0}:{1}", "getStudentTaskListAsync", getStudentsTaskResponse.Message));
    

    taskDescription = getStudentsTaskResponse.Records[0].Description;
    return taskDescription;
}
Get Student Activity Log Description by Student Id
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using YourServiceReferenceHere;


public SecurityToken GetAuth()
{
    SecurityToken securityToken = new SecurityToken()
    {
        Username = "Student Portal",
        UserId = -2,
        DashboardAdmin = true
    };

    return securityToken;
}

public async Task<string> GetStudentActivity()
{
    string studentActivityDescription = "";


    long studentId = 11313;
    GetActivityListRequest getActivityListRequest = new GetActivityListRequest();
    getActivityListRequest.SecurityToken = GetAuth();
    RegentEnterpriseServiceClient client = new RegentEnterpriseServiceClient();
    client.Endpoint.Address = new System.ServiceModel.EndpointAddress("http://regentremwsqa9.regenteducation.local/RegentEnterpriseWebService.svc");

    // here you cann add the different conditions as sorting and the number of returning rows
    //getActivityListRequest.filterCondition = "StudentId = " + studentId; // you can add additional filtering here
    getActivityListRequest.StudentId = studentId; // required
    getActivityListRequest.sortColumn = null;
    getActivityListRequest.sortExpression = null;
    getActivityListRequest.startRowIndex = 1; // start and end row indexes are required to provide
    getActivityListRequest.endRowIndex = 1;


    GetActivityListResponse getActivityListResponse = await client.getActivityListAsync(getActivityListRequest);

    if (!getActivityListResponse.Success)
        throw new ApplicationException(string.Format("Error calling {0}:{1}", "getActivityListAsync", getActivityListResponse.Message));
    

    studentActivityDescription = getActivityListResponse.Records[0].description;
    return studentActivityDescription;
}
Get Program Name by Student Id
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using YourServiceReferenceHere;


public SecurityToken GetAuth()
{
    SecurityToken securityToken = new SecurityToken()
    {
        Username = "Student Portal",
        UserId = -2,
        DashboardAdmin = true
    };

    return securityToken;
}

public async Task<string> GetActiveCourseEnrollmentProgramForStudent()
{
    string programName = "";


    long studentId = 11313;
    GetActiveCourseEnrollmentProgramForStudentRequest getActiveCourseEnrollmentProgramForStudentReques = new GetActiveCourseEnrollmentProgramForStudentRequest();
    getActiveCourseEnrollmentProgramForStudentReques.SecurityToken = GetAuth();
    RegentEnterpriseServiceClient client = new RegentEnterpriseServiceClient();
    client.Endpoint.Address = new System.ServiceModel.EndpointAddress("http://regentremwsqa9.regenteducation.local/RegentEnterpriseWebService.svc");

    // it's the only awailable filtering condition here
    getActiveCourseEnrollmentProgramForStudentReques.StudentId = studentId; // required


    GetCourseEnrollmentProgramResponse getCourseEnrollmentProgramResponse = await client.getActiveCourseEnrollmentProgramForStudentAsync(getActiveCourseEnrollmentProgramForStudentReques);

    if (!getCourseEnrollmentProgramResponse.Success)
        throw new ApplicationException(string.Format("Error calling {0}:{1}", "getActiveCourseEnrollmentProgramForStudentAsync", getCourseEnrollmentProgramResponse.Message));


    programName = getCourseEnrollmentProgramResponse.Record.ProgramName;
    return programName;
}
Get Course Name by Student Id
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using YourServiceReferenceHere;


public SecurityToken GetAuth()
{
    SecurityToken securityToken = new SecurityToken()
    {
        Username = "Student Portal",
        UserId = -2,
        DashboardAdmin = true
    };

    return securityToken;
}

public async Task<string> GetCourseDataList()
{
    string courseName = "";


    long studentId = 11313;
    GetCourseDataListRequest getCourseDataListRequest = new GetCourseDataListRequest();
    getCourseDataListRequest.SecurityToken = GetAuth();
    RegentEnterpriseServiceClient client = new RegentEnterpriseServiceClient();
    client.Endpoint.Address = new System.ServiceModel.EndpointAddress("http://regentremwsqa9.regenteducation.local/RegentEnterpriseWebService.svc");

    // here you cann add the different conditions as sorting and the number of returning rows
    getCourseDataListRequest.StudentId = studentId;
    //getCourseDataListRequest.filterCondition = "StudentId = " + studentId; // you can add additional filtering here
    getCourseDataListRequest.sortExpression = null;
    getCourseDataListRequest.startRowIndex = 1; // start and end row indexes are required to provide
    getCourseDataListRequest.endRowIndex = 1;


    GetCourseDataListResponse getCourseDataListResponse = await client.getCourseDataListAsync(getCourseDataListRequest);

    if (!getCourseDataListResponse.Success)
        throw new ApplicationException(string.Format("Error calling {0}:{1}", "getCourseDataListAsync", getCourseDataListResponse.Message));
    

    courseName = getCourseDataListResponse.Records[0].courseName;
    return courseName;
}
Get Accepted Amount by Amount
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using YourServiceReferenceHere;


public SecurityToken GetAuth()
{
    SecurityToken securityToken = new SecurityToken()
    {
        Username = "Student Portal",
        UserId = -2,
        DashboardAdmin = true
    };

    return securityToken;
}

public async Task<double?> GetAwards()
{
    double? acceptedAmount;


    int amount = 10000;
    GetAwardsRequest getAwardsRequest = new GetAwardsRequest();
    getAwardsRequest.SecurityToken = GetAuth();
    RegentEnterpriseServiceClient client = new RegentEnterpriseServiceClient();
    client.Endpoint.Address = new System.ServiceModel.EndpointAddress("http://regentremwsqa9.regenteducation.local/RegentEnterpriseWebService.svc");

    // here you cann add the different conditions as sorting and the number of returning rows
    getAwardsRequest.filterCondition = "amount > " + amount.ToString();
    getAwardsRequest.FundId = 59; //required
    getAwardsRequest.sortExpression = null;
    getAwardsRequest.sortColumn = null;
    getAwardsRequest.startRowIndex = 1; // start and end row indexes are required to provide
    getAwardsRequest.endRowIndex = 1;


    GetAwardsResponse getAwardsResponse = await client.getAwardsAsync(getAwardsRequest);

    if (!getAwardsResponse.Success)
        throw new ApplicationException(string.Format("Error calling {0}:{1}", "getAwardsAsync", getAwardsResponse.Message));

    // expect you'll get 1 and only 1 record. Adjust for your needs.
    if (getAwardsResponse.Records.Length != 1)
    {
        throw new ApplicationException(string.Format("Expected 1 student record but found {0} records", 0));
    }

    acceptedAmount = getAwardsResponse.Records[0].acceptedAmount;
    return acceptedAmount;
}
Get Documents by Status Code
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using YourServiceReferenceHere;


public SecurityToken GetAuth()
{
    SecurityToken securityToken = new SecurityToken()
    {
        Username = "Student Portal",
        UserId = -2,
        DashboardAdmin = true
    };

    return securityToken;
}

public async Task<GetStudentDocumentsLoadStudentListResponse> GetStudentDocumentsByStatusCode(string statusCode)
{
    
    GetStudentDocumentsLoadStudentListRequest getStudentDocumentsRequest = new GetStudentDocumentsLoadStudentListRequest();
    getStudentDocumentsRequest.SecurityToken = GetAuth();
    RegentEnterpriseServiceClient client = new RegentEnterpriseServiceClient();
    client.Endpoint.Address = new System.ServiceModel.EndpointAddress("http://regentremwsqa9.regenteducation.local/RegentEnterpriseWebService.svc");

    // here you cann add the different conditions as sorting and the number of returning rows
    getStudentDocumentsRequest.IOProcessId = 30; // required
    getStudentDocumentsRequest.sortColumn = null;
    getStudentDocumentsRequest.sortType = null;
    getStudentDocumentsRequest.filterCondition = "DocumentStatus = '" + statusCode + "'"; // here you can provide filtering conditions
    getStudentDocumentsRequest.startRowIndex = 1; // start and end row indexes are required to provide
    getStudentDocumentsRequest.endRowIndex = 10;


    GetStudentDocumentsLoadStudentListResponse getStudentsDocumentsResponse = await client.getStudentDocumentsLoadStudentListAsync(getStudentDocumentsRequest);

    if (!getStudentsDocumentsResponse.Success)
        throw new ApplicationException(string.Format("Error calling {0}:{1}", "getStudentDocumentsLoadStudentListAsync", getStudentsDocumentsResponse.Message));
    
    return getStudentsDocumentsResponse;
}
Get Sum of Disbursements by Award Id
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using YourServiceReferenceHere;


public SecurityToken GetAuth()
{
    SecurityToken securityToken = new SecurityToken()
    {
        Username = "Student Portal",
        UserId = -2,
        DashboardAdmin = true
    };

    return securityToken;
}

public async Task<double?> GetDisbursementAmountForAward()
{
    double amount;
    
    long awardId = 283;
    GetAwardDisbursementsRequest getAwardDisbursementsRequest = new GetAwardDisbursementsRequest();
    getAwardDisbursementsRequest.SecurityToken = GetAuth();
    RegentEnterpriseServiceClient client = new RegentEnterpriseServiceClient();
    client.Endpoint.Address = new System.ServiceModel.EndpointAddress("http://regentremwsqa9.regenteducation.local/RegentEnterpriseWebService.svc");

    // here you cann add the different conditions as sorting and the number of returning rows
    getAwardDisbursementsRequest.filterCondition = "awardId = " + awardId;
    getAwardDisbursementsRequest.sortExpression = null;
    getAwardDisbursementsRequest.sortColumn = null;
    getAwardDisbursementsRequest.startRowIndex = 1; // start and end row indexes are required to provide
    getAwardDisbursementsRequest.endRowIndex = 100;


    GetAwardDisbursementsResponse getAwardDisbursementsResponse = await client.getAwardDisbursementsAsync(getAwardDisbursementsRequest);

    if (!getAwardDisbursementsResponse.Success)
        throw new ApplicationException(string.Format("Error calling {0}:{1}", "getAwardsAsync", getAwardDisbursementsResponse.Message));
    

    amount = getAwardDisbursementsResponse.Records.AsEnumerable().Select(x => x.amount).Sum();
    return amount;
}
Create Document File Attachment
/* IMPORTANT!
** For using this example you need to uncheck the "Allow generation of asynchronous operation" option in advanced Service Reference settings*/

using System;
using System.Data;
using System.IO;
using YourServiceReferenceHere;

namespace ConsoleApp2
{
    class Program
    {
        public static SecurityToken GetAuth()
        {
            SecurityToken securityToken = new SecurityToken()
            {
                Username = "Student Portal",
                UserId = -2,
                DashboardAdmin = true
            };

            return securityToken;
        }
        static void Main(string[] args)
        {
            string filePath = "C:\\Users\\katie.macpherson\\Downloads\\test.txt";
            int documentRequirementId = 123456;
            int studentId = 4996;

            CreateDocumentFileAttachment(documentRequirementId, filePath, mimeType, studentId);

        }
        static void CreateDocumentFileAttachment(int documentRequirementId, string filePath, string mimeType, int studentId)
        {
            using (var client = new RegentEnterpriseServiceClient())
            {
                var file = new FileInfo(filePath);
                var record = new DocumentRequirementFileAttachment()
                {
                    DocumentRequirementId = documentRequirementId,
                    DocumentRequirementIdSpecified = true,
                    FileName = file.Name,
                    FileSize = file.Length,
                    FileSizeSpecified = true,
                    MimeType = mimeType,                    
                    StoredFile = File.ReadAllBytes(file.FullName),                                       
                    isFileExists = false,
                    isFileExistsSpecified = true,
                    CreatedOn = DateTime.Now,
                    CreatedOnSpecified = true,
                    ModifiedOn = DateTime.Now,
                    ModifiedOnSpecified = true,                   
                };

                var createDocumentAttachmentRequest = new UpdateDocumentRequirementFileAttachmentRequest
                {
                    Record = record,
                    StudentId = studentId,
                    StudentIdSpecified = true,
                    SecurityToken = GetAuth(),
                };
                var response = client.createDocumentRequirementFileAttachment(createDocumentAttachmentRequest);

                if (response.ErrorYN)
                {
                    throw new Exception(response.Message);
                }
            }
        }
	}
}
Update Document File Attachment
/* IMPORTANT!
** For using this example you need to uncheck the "Allow generation of asynchronous operation" option in advanced Service Reference settings*/

using System;
using System.Data;
using System.IO;
using YourServiceReferenceHere;

namespace ConsoleApp2
{
    class Program
    {
        public static SecurityToken GetAuth()
        {
            SecurityToken securityToken = new SecurityToken()
            {
                Username = "Student Portal",
                UserId = -2,
                DashboardAdmin = true
            };

            return securityToken;
        }
        static void Main(string[] args)
        {
            int documentRequirementFileAttachmentId= /*ID here*/;

            UpdateDocumentFileAttachment(documentRequirementFileAttachmentId, "test comment"); // You can update only a comment

        }
        static void UpdateDocumentFileAttachment(int documentRequirementFileAttachmentId, string comment)
        {
            using (var client = new RegentEnterpriseServiceClient())
            {
                var record = new DocumentRequirementFileAttachment()
                {
                    Id = documentRequirementFileAttachmentId,
                    IdSpecified = true,
                    Comments = comment,
                    ModifiedBy = -168,
                    ModifiedBySpecified = true,
                    ModifiedOn = DateTime.Now,
                    ModifiedOnSpecified = true
                };
                var updateDocumentAttachmentRequest = new UpdateDocumentRequirementFileAttachmentRequest
                {
                    Record = record,
                    SecurityToken = GetAuth()
                };
                var response = client.updateDocumentRequirementFileAttachment(updateDocumentAttachmentRequest);

                if (response.ErrorYN)
                {
                    throw new Exception(response.Message);
                }
            }
        }
	}
}
Delete Document File Attachment
/* IMPORTANT!
** For using this example you need to uncheck the "Allow generation of asynchronous operation" option in advanced Service Reference settings*/

using System;
using System.Data;
using System.IO;
using YourServiceReferenceHere;

namespace ConsoleApp2
{
    class Program
    {
        public static SecurityToken GetAuth()
        {
            SecurityToken securityToken = new SecurityToken()
            {
                Username = "Student Portal",
                UserId = -2,
                DashboardAdmin = true
            };

            return securityToken;
        }
        static void Main(string[] args)
        {
            int documentRequirementFileAttachmentId= /*ID here*/;

            DeleteDocumentFileAttachment(documentRequirementFileAttachmentId);

        }
        static void DeleteDocumentFileAttachment(int documentRequirementFileAttachmentId)
        {
            using (var client = new RegentEnterpriseServiceClient())
            {
                var record = new DocumentRequirementFileAttachment()
                {
                    Id = documentRequirementFileAttachmentId,
                    IdSpecified = true,
                    DeletedBy = 168,
                    DeletedBySpecified = true,
                    DeletedOn = DateTime.Now,
                    DeletedOnSpecified = true,
                    DocumentRequirementId = 104128,
                    DocumentRequirementIdSpecified = true,
                };
                var deleteDocumentAttachmentRequest = new UpdateDocumentRequirementFileAttachmentRequest
                {
                    Record = record,
                    SecurityToken = GetAuth()
                };
                var response = client.deleteDocumentRequirementFileAttachment(deleteDocumentAttachmentRequest);

                if (response.ErrorYN)
                {
                    throw new Exception(response.Message);
                }
            }
        }
	}
}
Get Login List
/* IMPORTANT!
** For using this example you need to uncheck the "Allow generation of asynchronous operation" option in advanced Service Reference settings*/

using System;
using System.Data;
using System.IO;
using YourServiceReferenceHere;

namespace ConsoleApp2
{
    class Program
    {
        public static SecurityToken GetAuth()
        {
            SecurityToken securityToken = new SecurityToken()
            {
                Username = "Student Portal",
                UserId = -2,
                DashboardAdmin = true
            };

            return securityToken;
        }
        static void Main(string[] args)
        {
            DataTable loginList = new DataTable();

            loginList = GetLoginList();
        }
        static DataTable GetLoginList()
        {
            DataTable login = new DataTable();
            login.Columns.Add("LoginId", typeof(long));
            login.Columns.Add("Username", typeof(string));
            login.Columns.Add("Email", typeof(string));
            login.Columns.Add("FirstName", typeof(string));
            login.Columns.Add("LastName", typeof(string));
            login.Columns.Add("IsActive", typeof(bool));

            using (var client = new RegentEnterpriseServiceClient())
            {
                var getLoginListRequest = new GetLoginListRequest()
                {
                    startRowIndex = 0,
                    startRowIndexSpecified = true,
                    endRowIndex = 100000,
                    endRowIndexSpecified = true,
                    SecurityToken = GetAuth()
                };
                var records = client.getLoginList(getLoginListRequest).Records;

                foreach(var record in records)
                {
                    DataRow row = login.NewRow();

                    row["LoginId"] = record.LoginId;
                    row["Username"] = record.Username;
                    row["Email"] = record.Email;
                    row["FirstName"] = record.FirstName;
                    row["LastName"] = record.LastName;
                    row["IsActive"] = record.IsActive;

                    login.Rows.Add(row);
                }
            }
            return login;
        }
    }
}
Create DocumentRequirement by StudentId
/* IMPORTANT!
** For using this example you need to uncheck the "Allow generation of asynchronous operation" option in advanced Service Reference settings*/

using System;
using System.Data;
using System.IO;
using YourServiceReferenceHere;

namespace ConsoleApp2
{
    class Program
    {
        public static SecurityToken GetAuth()
        {
            SecurityToken securityToken = new SecurityToken()
            {
                Username = "Student Portal",
                UserId = -2,
                DashboardAdmin = true
            };

            return securityToken;
        }
        static void Main(string[] args)
        {
            CreateStudentDocumentRequirement(/*documentId*/, /*studentId*/);
        }
        static void CreateStudentDocumentRequirement(Int64 documentId, Int64 studentId)
        {
            using (var client = new RegentEnterpriseServiceClient())
            {
                var record = new DocumentRequirement()
                {
                    // All fields below are required
                    documentId = documentId,
                    documentIdSpecified = true,
                    studentId = studentId,
                    studentIdSpecified = true,
                    ActivitySourceTypeCode = "SYSTEMACTION",
                    ActivityLogEntryTypeCode = "QARelated",
                    createdDate = DateTime.Now,
                    createdDateSpecified = true,
                    CreatedBy = 1,
                    CreatedBySpecified = true,
                    reviewedDate = DateTime.UtcNow,
                    reviewedDateSpecified = true,
                    receivedDate = DateTime.UtcNow,
                    receivedDateSpecified = true,
                    EditLockTimestamp = DateTime.UtcNow,
                    EditLockTimestampSpecified = true,
                    Files = new DocumentRequirementFileAttachment[] { }
                };
                var createDRReques = new UpdateDocumentRequirementRequest
                {
                    Record = record,
                    SecurityToken = GetAuth()
                };
                var response = client.createDocumentRequirement(createDRReques);

                if (response.ErrorYN)
                {
                    throw new Exception(response.Message);
                }
            }
        }
    }
}
Download Document Requirement File Attachment (using documentRequirementFileAttachmentId)
/* IMPORTANT!
** For using this example you need to uncheck the "Allow generation of asynchronous operation" option in advanced Service Reference settings*/

using System;
using System.Data;
using System.IO;
using YourServiceReferenceHere;

namespace ConsoleApp2
{
    class Program
    {
        public static SecurityToken GetAuth()
        {
            SecurityToken securityToken = new SecurityToken()
            {
                Username = "Student Portal",
                UserId = -2,
                DashboardAdmin = true
            };

            return securityToken;
        }
        static void Main(string[] args)
        {
            GetFileFromDocumentRequirementFileAttachmentById(/*documentRequirementIdFileAttachmentId*/, /*Target folder path*/);
        }
		static void GetFileFromDocumentRequirementFileAttachmentById(int documentRequirementIdFileAttachmentId, string targetFolder)
        {
            using (var client = new RegentEnterpriseServiceClient())
            {
                var request = new GetDocumentRequirementFileAttachmentRequest
                {
                    SecurityToken = GetAuth(),
                    Id = documentRequirementIdFileAttachmentId,
                    IdSpecified = true,
                };

                var record = client.getDocumentRequirementFileAttachment(request).Record;
                
                if (record.StoredFile.Length > 0)
                {
                    File.WriteAllBytes(Path.Combine(targetFolder, record.FileName), record.StoredFile);
                }
            }
        }
    }
}