Using Bizview API to Get Data from Your Application
This topic provides examples for using Bizview APIs to execute a Dataview in order to fetch data.
This topic contains the following sections:
Authentication
Before you can use Bizview APIs, you must authenticate with Bizview. Otherwise, it is not possible to use any API call.
HTTP Request
POST <bizviewurl>/api/authication/authenticate
Parameters
AuthenticationMethod {
string name // Should be "basic"
credentials: {
string username, // The Bizview user
string password, // The password
string client // Client to login to
}
}
Example
publicasyncTask<object> Login(string id, string password, string client)
{
HttpClient httpClient = newHttpClient();
httpClient.BaseAddress = newUri("http://www.yourwebapp.com");
httpClient.DefaultRequestHeaders.Accept.Clear();
httpClient.DefaultRequestHeaders.Accept.Add(newMediaTypeWithQualityHeaderValue("application/json"));
var authenticationMethod = new
{
Name = "basic",
Credentials = new
{
Client = client,
Username = id,
Password = password
}
};
HttpResponseMessage response = await httpClient.PostAsJsonAsync("api/authentication/authenticate", authenticationMethod);
response.EnsureSuccessStatusCode();
var result == await response.Content.ReadAsAsync<object>();
var user = Json.Decode(result.ToString());
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", user.Session.Token)
}
Dataview
HTTP Request
GET <bizviewurl>/api/dataview?id=dataviewId&top=topRows
Parameters
Id String: The dataview id to be executed.
top Int: Top rows to be returned. Pass 0 to get all rows.
Example
Note: The httpClient used here must be the one created in the login method above!
publicasyncTask<object> GetData(string id, )
{
HttpResponseMessage response = await httpClient.GetAsync($"api/dataview?id= {id}&top={topRows}");
response.EnsureSuccessStatusCode();
var result =await response.Content.ReadAsAsync<object>();
var dataviewResult = Json.Decode(result.ToString());
// dataviewResult.Data will contain the data from the dataview
}