ASAP a Connexeo Company

Introducing the ASAP API

Authetication.

Authentication variables.

In order to authenticate with the ASAP API, the code needs to write the authentication data in the “Authorization” header.

Note: Every request is going to work with the same idea. Create an HttpRequest object with the URL; create the authorization or access token in the header; changes the Accept or Content Type property; wait for the response.

The authentication needs the username, the password and the organization id, joined in a key/value pair format with an equals character (=), and joined all together with an ampersand (&).

Example: user=username&password=password&organizationId=organizationId&apiKey=apikey.

Note: the username and password is unique to your integration application, and is not related to your regular ASAP application credentials.

 HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://stagingapi.asapconnected.com/api/login");
request.Headers.Add(HttpRequestHeader.Authorization, "user=username&organizationId=id&password=password&apiKey=apikey");
request.Accept = "application/json";
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
string accessToken = response.Headers["asap_accesstoken"];

The access token is in the headers of the response. Every time you need to make a call to the API, you need to send this access token to get authorized. The access token has a 2 hour life, and then gets rejected so you need to send the authorization variables again.

Top

Access token

Once you get the access token, you need to send it every time you make a request in the headers.


 HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://stagingapi.asapconnected.com/api/invoice(1000)/summary");
request.Headers.Add("asap_accesstoken", "access_token");
request.Accept = "application/json";
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
string accessToken = response.Headers["asap_accesstoken"];

In order to avoid be rejected every 2 hours, you should send “Authorization” header every time you make a request. The ASAP API will send you the new access token in the header of the response.

Top