April 25, 2016

Birst Web Services – Getting Started

Birst Web Services allows you to extend birst functionality into your applications, or portals without going through Admin UI or command windows, following is the blog post on how to use “Birst Web Services”.

How to utilize Birst Web Services?

  • Web Services can be used for Single Sign On (SSO) purpose.
  • Connect to the third party data sources via Web Services Commands.
  • Most currently supported administrative commands are exposed through these web services along with additional commands such as Login and Logout.
  • Able to access the dashboards properties via Birst web services command.
  • Able to extract the data from default connector from birst like sales force using birst web services command.

How to access Birst Web Services?

Step by Step Process for Accessing Web Services:

  1. Open Visual Studio and Create a new Windows/Web Application.
  2. Right click on the Reference tab and select Add Reference.
  3. Click on the Advanced option in the Reference Window
  4. Click on the Web Reference Option at the bottom of the Reference Window (Screenshot attached below)
  5. Type the above Service URL in the Address Bar.
  6. Click on the Add Reference.
  7. The reference namespace will be added to your code usingbirst.bws.app2101;

E

Workflow

  • An example workflow for processing data in a space would look like this:
  • Login > publishData > isJobComplete > getJobStatus > Logout
  • All operations occur within a single session that is initiated with a call to Login and ends with a call to Logout.

Sample Code:

Creating the object for web services:

CommandWebService cws = new CommandWebService();

Include the SSL and TSL Security object (For TLS Version 1.1) :

System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls11;

Include the SSL and TSL Security object (For TLS Version 1.2) :

System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;

Login :

public string Birst_Login(string un,string pwd)
{
try
{
cws.Url = BASEURL + "/CommandWebService.asmx";
string LoginToken = cws.Login(UserName, Password); \\ this will return the login token
return LoginToken;
}
catch(Exception e)
{
MessageBox.Show(e.Message);
return null;
}
}

Space Access :

public void Get_Space(string Login_Token)
{
try
{
spaces = cws.listSpaces(Login_Token);
for (int i = 0; i < spaces.Length; i++)
{
Space[i]=(i, spaces[i].name);
}
}
catch(Exception e)
{
MessageBox.Show(e.Message);
}
}

Upload and Process the Data:

public void upload_process()
{
try
{
byte[] arrays = System.IO.File.ReadAllBytes(filepath);

//Get the token for data upload
String DataToken = cws.beginDataUpload(LoginToken, spaceid,filepath);

//Begin data upload
cws.uploadData(LoginToken, DataToken, arrays.Length, arrays);

//Finishing the data upload
cws.finishDataUpload(LoginToken, DataToken);

//validating the uploaded data
bool check = cws.isDataUploadComplete(LoginToken, DataToken);

cws.publishData(LoginToken, spaceid, null,Timestamp);
cws.publishDataAsync(LoginToken, spaceid, null, Timestamp);
}
catch(Exception e)
{
MessageBox.Show(e.Message);
}
}

Logout:

public void Birst_Logout(string un,string pwd)
{
try
{
cws.Logout(LoginToken);
}
catch(Exception e)
{
MessageBox.Show(e.Message);
}
}

To be Continued ….

Birst, Technology