Below is a C# example of using your ApplicantStack data in a .Net Environment. There is a class that defines the layout of the return structure from ApplicantStack that also provides methods to fill the data (ApplicantStackJobData.cs) and 2 web form pages to present all of your Open listings (JobListing.aspx) and to show you details of each individual listing(JobDefinition.aspx – Please note that this example shows only what we deemed relevant as there are numerous bits of information in the JobInformation class). Simply copy the code below and change the baseURI to your applicant stack website address, Token and Publisher strings in the ApplicantStackJobData class with those relevant to your company. The Token can be found by logging into your ApplicantStack account and go into your company setting. There you will find a section named API Settings. Copy the unique value to the right of the label “API Access Token:” and remove any leading or trailing spaces.
ApplicantStackJobData.cs
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Headers;
using Newtonsoft.Json; //Version 4.5.6.14930
//This is for .Net 4.0.
//This Class requires the Newtonsoft.Json component (You can choose what your comfortable working with)
//To Get Started please read
//http://help.applicantstack.com/kb/applicantstack-api/api-integration-guide
public class ApplicantStackJobData
{
public string baseURI = "https://MYCOMPANY.applicantstack.com/"; //Add the link to your companies applicant stack website
public string Token = "MYCOMPANYTOKENFROMAPPLICANTSTACK"; //Add the link to your companies applicant stack Token
public string Publisher = "PUBLISHER NAME"; //Add the Publisher name
public ApplicantStackJobData()
{
//
// TODO: Add constructor logic here
//
}
}
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
public class JobListingPage
{
[JsonProperty(PropertyName = "Method Result")]
public string Method_Result { get; set; }
[JsonProperty(PropertyName = "Page")]
public int Page { get; set; }
[JsonProperty(PropertyName = "NumPages")]
public int NumPages { get; set; }
[JsonProperty(PropertyName = "TotalCount")]
public int TotalCount { get; set; }
[JsonProperty(PropertyName = "Jobs")]
public List<Jobs> JobList { get; set; }
}
public class JobDataJob
{
public JobDataJob()
{
//Initialize();
}
public JobInformation GetJobInformation(string ThisJobID)
{
JobInformation SingleJobInfo = new JobInformation();
ApplicantStackJobData MyApplicantStackInfo = new ApplicantStackJobData();
HttpClient client = new HttpClient();
client.BaseAddress = new Uri(MyApplicantStackInfo.baseURI.ToString().Trim());
client.DefaultRequestHeaders.Add("Token", MyApplicantStackInfo.Token);
client.DefaultRequestHeaders.Add("Publisher", MyApplicantStackInfo.Publisher);
// Add an Accept header for JSON format.
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
HttpResponseMessage response = client.GetAsync("api/job/" + ThisJobID.Trim()).Result;
if (response.IsSuccessStatusCode)
{
var jobs = response.Content.ReadAsStringAsync();
SingleJobInfo = JsonConvert.DeserializeObject<JobInformation>(jobs.Result);
}
else
{
//We are choosing to ignore errors. However, you or your company may choose not to.
}
return SingleJobInfo;
}
}
public class JobsData
{
public JobsData()
{
//Initialize();
}
public List<Jobs> GetAllJobs()
{
List<Jobs> MyJobs = new List<Jobs>();
ApplicantStackJobData MyApplicantStackInfo = new ApplicantStackJobData();
HttpClient client = new HttpClient();
client.BaseAddress = new Uri(MyApplicantStackInfo.baseURI.ToString().Trim());
client.DefaultRequestHeaders.Add("Token", MyApplicantStackInfo.Token);
client.DefaultRequestHeaders.Add("Publisher", MyApplicantStackInfo.Publisher);
// Add an Accept header for JSON format.
client.DefaultRequestHeaders.Accept.Add( new MediaTypeWithQualityHeaderValue("application/json"));
HttpResponseMessage response = client.GetAsync("api/jobs").Result;
if (response.IsSuccessStatusCode)
{
var jobs = response.Content.ReadAsStringAsync();
JobListingPage model = null;
model = JsonConvert.DeserializeObject<JobListingPage>(jobs.Result);
foreach (Jobs curjob in model.JobList)
{
MyJobs.Add(curjob);
}
//Multiple Pages
//api/jobs/2?stage=Open&jobboard=applicantstack and then api/jobs/3?stage=Open&jobboard=applicantstack
if (model.NumPages > 1)
{
//The Code Below Retrieves all of the pages into one dataset. You could write your gridview to show 100
//records and then page and have the gridview databind by page number.
int I = model.NumPages;
for (int j = 2; j <= I; j++)
{
HttpResponseMessage moreresponses = client.GetAsync("api/jobs/" + j.ToString()).Result;
if (moreresponses.IsSuccessStatusCode )
{
var morejobs = moreresponses.Content.ReadAsStringAsync();
JobListingPage moremodel = null;
moremodel = JsonConvert.DeserializeObject<JobListingPage>(morejobs.Result);
foreach (Jobs morecurjob in model.JobList)
{
MyJobs.Add(morecurjob);
}
}
}
//End Numerous pages
}
}
else
{
//We are choosing to ignore errors. However, you or your company may choose not to.
}
return MyJobs;
}
}
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
public class Jobs
{
[JsonProperty(PropertyName = "Job Serial")]
public string Job_Serial { get; set; }
[JsonProperty(PropertyName = "Job Name")]
public string Job_Name { get; set; }
[JsonProperty(PropertyName = "Stage")]
public string Stage { get; set; }
[JsonProperty(PropertyName = "Department")]
public string Department { get; set; }
[JsonProperty(PropertyName = "HIring Manager")]
public string HIring_Manager { get; set; }
[JsonProperty(PropertyName = "Territory")]
public string Territory { get; set; }
[JsonProperty(PropertyName = "Location")]
public string Location { get; set; }
[JsonProperty(PropertyName = "Job Type")]
public string Job_Type { get; set; }
[JsonProperty(PropertyName = "Job Category")]
public string Job_Category { get; set; }
[JsonProperty(PropertyName = "Classification")]
public string Classification { get; set; }
[JsonProperty(PropertyName = "Status")]
public string Status { get; set; }
[JsonProperty(PropertyName = "Shift")]
public string Shift { get; set; }
[JsonProperty(PropertyName = "Openings")]
public string Openings { get; set; }
[JsonProperty(PropertyName = "Campaign Start Date")]
public string Campaign_Start_Date { get; set; }
[JsonProperty(PropertyName = "Create Date")]
public string Create_Date { get; set; }
}
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
public class JobInformation
{
[JsonProperty(PropertyName = "Method Result")]
public string Method_Result { get; set; }
[JsonProperty(PropertyName = "Job Serial")]
public string Job_Serial { get; set; }
[JsonProperty(PropertyName = "Job Name")]
public string Job_Name { get; set; }
[JsonProperty(PropertyName = "Stage")]
public string Stage { get; set; }
[JsonProperty(PropertyName = "Job Listing")]
public string Job_Listing { get; set; }
[JsonProperty(PropertyName = "Job Listing Html")]
public string Job_Listing_Html { get; set; }
[JsonProperty(PropertyName = "Questionnaire Serials")]
public string[] Questionnaire_Serials { get; set; }
[JsonProperty(PropertyName = "Scoring Serials")]
public string[] Scoring_Serials { get; set; }
[JsonProperty(PropertyName = "Department")]
public string Department { get; set; }
[JsonProperty(PropertyName = "HIring Manager")]
public string HIring_Manager { get; set; }
[JsonProperty(PropertyName = "Territory")]
public string Territory { get; set; }
[JsonProperty(PropertyName = "Location")]
public string Location { get; set; }
[JsonProperty(PropertyName = "Job Type")]
public string Job_Type { get; set; }
[JsonProperty(PropertyName = "Job Category")]
public string Job_Category { get; set; }
[JsonProperty(PropertyName = "Classification")]
public string Classification { get; set; }
[JsonProperty(PropertyName = "Status")]
public string Status { get; set; }
[JsonProperty(PropertyName = "Shift")]
public string Shift { get; set; }
[JsonProperty(PropertyName = "Openings")]
public string Openings { get; set; }
[JsonProperty(PropertyName = "Campaign Start Date")]
public string Campaign_Start_Date { get; set; }
[JsonProperty(PropertyName = "Create Date")]
public string Create_Date { get; set; }
}
JobDefinition.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="JobDefinition.aspx.cs" Inherits="JobDefinition" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="GetJobInformation" TypeName="JobDataJob">
<SelectParameters>
<asp:QueryStringParameter Name="ThisJobID" QueryStringField="PostID" Type="String" />
</SelectParameters>
</asp:ObjectDataSource>
<asp:DataList ID="DataList1" runat="server" DataSourceID="ObjectDataSource1" CssClass="EmployeeReferralDataList">
<ItemTemplate>
<asp:Label ID="HeaderJobDescription" CssClass="EmployeeReferralHeaderJobDescription" runat="server" Text='<%# Eval("Job_Name") %>' />
<br />
<br />
<div class="EmployeeReferralBannerDiv">Summary</div>
<table>
<tr>
<td style="text-align: right; padding-right: 5px;">Title:</td>
<td style="padding-left: 10px;">
<asp:Label ID="Job_NameLabel" runat="server" Text='<%# Eval("Job_Name") %>' /></td>
</tr>
<tr>
<td style="text-align: right; padding-right: 5px;">Department:</td>
<td style="padding-left: 10px;">
<asp:Label ID="DepartmentLabel" runat="server" Text='<%# Eval("Department") %>' /></td>
</tr>
<tr>
<td style="text-align: right; padding-right: 5px;">Location:</td>
<td style="padding-left: 10px;">
<asp:Label ID="LocationLabel" runat="server" Text='<%# Eval("Location") %>' /></td>
</tr>
<tr>
<td style="text-align: right; padding-right: 5px;">Classification:</td>
<td style="padding-left: 10px;">
<asp:Label ID="ClassificationLabel" runat="server" Text='<%# Eval("Classification") %>' /></td>
</tr>
<tr>
<td style="text-align: right; padding-right: 5px;">Status:</td>
<td style="padding-left: 10px;">
<asp:Label ID="StatusLabel" runat="server" Text='<%# Eval("Status") %>' /></td>
</tr>
<tr>
<td style="text-align: right; padding-right: 5px;">Shift:</td>
<td style="padding-left: 10px;">
<asp:Label ID="ShiftLabel" runat="server" Text='<%# Eval("Shift") %>' /></td>
</tr>
<tr>
<td style="text-align: right; padding-right: 5px;">Openings:</td>
<td style="padding-left: 10px;">
<asp:Label ID="OpeningsLabel" runat="server" Text='<%# Eval("Openings") %>' /></td>
</tr>
</table>
<div class="EmployeeReferralBannerDiv">Description</div>
<br />
<asp:Label ID="Job_Listing_HtmlLabel" runat="server" Text='<%# Eval("Job_Listing_Html") %>' />
<br />
</ItemTemplate>
</asp:DataList>
</div>
</form>
</body>
</html>
JobListing.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="JobListing.aspx.cs" Inherits="JobListing" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="GetAllJobs" TypeName="JobsData"></asp:ObjectDataSource>
<asp:GridView ID="ApplicantStackJobListings" runat="server" AutoGenerateColumns="False" DataSourceID="ObjectDataSource1" BackColor="White" BorderColor="#DEDFDE" BorderStyle="None" BorderWidth="1px" CellPadding="4" ForeColor="Black" GridLines="Vertical" Width="100%">
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:HyperLinkField DataNavigateUrlFormatString="JobDefinition.aspx?PostID={0}" DataTextField="Job_Name" HeaderText="Title" Target="_self" DataNavigateUrlFields="Job_Serial" />
<asp:BoundField DataField="Department" HeaderText="Department" />
<asp:BoundField DataField="Location" HeaderText="Location" />
<asp:BoundField DataField="Classification" HeaderText="Classification" />
<asp:BoundField DataField="Status" HeaderText="Status" />
<asp:BoundField DataField="Shift" HeaderText="Shift" />
<asp:BoundField DataField="Openings" HeaderText="Openings" />
<asp:BoundField DataField="Stage" HeaderText="Stage" />
</Columns>
<FooterStyle BackColor="#CCCC99" />
<HeaderStyle BackColor="#663300" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#F7F7DE" ForeColor="Black" HorizontalAlign="Right" />
<RowStyle BackColor="#FBFBEE" CssClass="PhoneGridViewHover" />
<SelectedRowStyle BackColor="#CE5D5A" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#FBFBF2" />
<SortedAscendingHeaderStyle BackColor="#848384" />
<SortedDescendingCellStyle BackColor="#EAEAD3" />
<SortedDescendingHeaderStyle BackColor="#575357" />
</asp:GridView>
</div>
</form>
</body>
</html>
Comments
0 comments
Article is closed for comments.