C# Sample Code
Downloadable Sample Solution
The source code below illustrates some aspects of submitting claims to Apex EDI. For a more complete example, download the sample solution.
Note: When submitting test claims on the sandbox system, the payer ID APX14116 must be used.
Compact Example
.NET Libraries
using System; using System.Net; using System.Net.Http; using System.Text;
Authentication
All API calls require authentication which must be included in the HttpClient header:
// sample key sample password string creds = "XORVKPEAWPCGV1QUEXWPO34N" + ":" + "JA1TSZNKTQOFK4WOHIWQ0K9D"; byte[] bcreds = Encoding.ASCII.GetBytes(creds); string base64Creds = Convert.ToBase64String(bcreds); HttpClient client = new HttpClient { BaseAddress = new Uri(ServiceBaseURL) }; client.DefaultRequestHeaders.Add("Authorization", "Basic " + base64Creds);
API Calling Convention
For each API HTTP call, there is a HttpResponseMessage that is returned. This can be viewed by reading the Content property as a string.
APIs can be called in the following way, using the HttpClient:
HttpResponseMessage _response = client.PostAsync("payers/get_list?vendorSiteId=000_Client&type=Medical", null).Result;
or
HttpResponseMessage_response = client.PostAsJsonAsync("claims/submit?vendorSiteId=MyVendorSiteId", claimforms).Result;
Sample Code - C#
using System; using System.Net; using System.Net.Http; using System.Text; namespace SampleAppV3 { class Program { private static HttpResponseMessage _response; private static string _token; private const string ServiceBaseURL = "http://sandbox.services.apexedi.com/api/v3/"; static void Main(string[] args) { // NOTE: These credentials are for documentation purposes only, please replace with your credentials string creds = "P34NOPEA453211QUEXWOXRVK" + ":" + "JA12345KTQOFK4WOHIWQ0J5D"; byte[] bcreds = Encoding.ASCII.GetBytes(creds); string base64Creds = Convert.ToBase64String(bcreds); HttpClient client = new HttpClient { BaseAddress = new Uri(ServiceBaseURL) }; client.DefaultRequestHeaders.Add("Authorization", "Basic " + base64Creds); try { // NOTE: The vendorSiteId supplied here is for documentation purposes only, please replace with your vendorSiteId _response = client.PostAsync( "claims/status/get_by_date?vendorSiteId=000_Client&startDate=2016-06-12&endDate=2016-06-16", null).Result; if (_response.StatusCode == HttpStatusCode.Accepted) { string results = _response.Content.ReadAsStringAsync().Result; } } catch (Exception e) { Console.WriteLine(e); throw; } } } }