C# Java JavaScript
using System.Net;
using System.Net.Http;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Json;
using System.Web.Script.Serialization;
...
using (HttpClient httpClient = new HttpClient())
{
// Get Session Id
string logonUri = "http://localhost:8004/Api/LogOn/";
var logonOptions = new
{
accountName = "admin",
password = "1234",
cultureName = string.Empty,
deleteOtherSessions = true,
isWindowsLogOn = false
};
JavaScriptSerializer serializer = new JavaScriptSerializer();
var requestBodyAsString = serializer.Serialize(logonOptions);
StringContent content =
new StringContent(
requestBodyAsString,
Encoding.UTF8,
"application/json"
);
string jsonString = string.Empty;
using (var response = httpClient.PostAsync(logonUri, content).Result)
{
jsonString =
response.Content.ReadAsStringAsync().Result;
}
var obj = (Dictionary<string,object>) serializer.DeserializeObject(jsonString);
string sessionId = obj["sessionId"].ToString();
string url = "http://localhost:8004/API/License/?sessionId=" + sessionId + "";
// Define the request body
HttpContent requestBody = null;
requestBody =
new StringContent(@"
""\u003cLicense\u003e\r\n \u003cId\u003e10\u003c/Id\u003e\r\n \u003cLicenseVersion\u003e1\u003c/LicenseVersion\u003e\r\n \u003cLicensee\u003eDundas BI Evaluation User\u003c/Licensee\u003e\r\n \u003cDescription\u003eThe initial Dundas BI license included during deployment.\u003c/Description\u003e\r\n \u003cCpuCoreCount\u003e2147483647\u003c/CpuCoreCount\u003e\r\n \u003cEnabledFeatureIds\u003e\r\n \u003cItem\u003ef36f9244-f363-4f6b-bf54-779d1c0e8123\u003c/Item\u003e\r\n \u003c/EnabledFeatureIds\u003e\r\n \u003cLicenseKind\u003eEvaluation\u003c/LicenseKind\u003e\r\n \u003cProductVersion\u003e4.0\u003c/ProductVersion\u003e\r\n \u003cReleaseKind\u003eAlpha\u003c/ReleaseKind\u003e\r\n \u003cServerCount\u003e100\u003c/ServerCount\u003e\r\n \u003cFloatingPowerUserSeatAllowance\u003e2:0:0\u003c/FloatingPowerUserSeatAllowance\u003e\r\n \u003cFloatingStandardUserSeatAllowance\u003e10:0:0\u003c/FloatingStandardUserSeatAllowance\u003e\r\n \u003cReservedDeveloperSeatAllowance\u003e6:0:0\u003c/ReservedDeveloperSeatAllowance\u003e\r\n \u003cReservedPowerUserSeatAllowance\u003e2:0:0\u003c/ReservedPowerUserSeatAllowance\u003e\r\n \u003cReservedStandardUserSeatAllowance\u003e10:0:0\u003c/ReservedStandardUserSeatAllowance\u003e\r\n \u003cSignature\u003eK5gRAuB70ncH69XQssfZ9U13XvBTtMwJVP+Np8SHBK+QFl70ez1EPPsO2FnbeFYpEZOWdRiL9TntAbAul91rvChGM2/Jj3MwtntkhvNFLvIXkLIk+BnlcLq2xTDVCP4LyyXvZsoz7AeHgCuvAkHdpnXdi8ZIpIfJFrT5KwrpeI9sFFHQBNFFVT/tftBFlp/ppXxsCNT3FofCtKMGqtPwAnnhEpnXZxOPmIHq40n3Yl8m2PsEgFIaJWRCQ2pxT6nrjcGmZuwFr2YhbBMWrsDUf6JshRS2Qh9I4Qn3rBYSHPJ/mSUaFliLqKIOEzBMwEmu9siamK9xoTVNV8iRuXDnGA==\u003c/Signature\u003e\r\n \u003cSignature2\u003ejgJnJwv9hvxeBKGfjwbr2b6g1pvxTHvkVtg2YnABaBYEo/1xafzopWTpj+kRA3UxhK7l0Do1n/jT+rFxd4xMd/N2Yfo7NNyPE1O7OidL3ovKO68NTcBuonJ5EWEsD/jA/Q0AFC/YIMvNlw+54WwzGNLRderpjawelC/Ey+qdusYJEiMD/WnQ+uyRezDpaKlzidFp/W0yufJqp5G/1DxUV78oFO/hW888iq+YGWvubOwIdEXNb9h/kArm0Xx6d1VG+6DZ3WA70xYtX5AJKuQxDGsTR8WZTcBG2EgyEegQWmV2xTFbjIa/TdTwOdLZi7GgRjJRx29ahG09MEjAsXoOKA==\u003c/Signature2\u003e\r\n\u003c/License\u003e"" ",Encoding.UTF8,"application/json");
using (var response = httpClient.PostAsync(url, requestBody).Result)
{
if(response.StatusCode == HttpStatusCode.OK)
{
Console.WriteLine("Success");
// The status code indication of success or
// reason of failure.
string jsonObject = response.Content.ReadAsStringAsync().Result;
}
}
}
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPut;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils;
import org.apache.http.entity.StringEntity;
import org.json.JSONObject;
...
HttpClient httpClient = HttpClientBuilder.create().build();
String url = "http://localhost:8004";
// Get Session Id
String logonUri = url + "Api/LogOn/"
HttpPost httpPost = new HttpPost(logonUri);
StringEntity stringEntity =
new StringEntity("{
+ "\"accountName\":\"admin\","
+ "\"password":\"1234\","
+ "\"cultureName\":\"\","
+ "\"deleteOtherSessions\":false,"
+ "\"isWindowsLogOn\":false"
+ "}"
);
stringEntity.setContentType("application/json");
httpPost.setEntity(stringEntity);
HttpResponse httpResponse = httpClient.execute(httpPost);
String jsonString = EntityUtils.toString(httpResponse.getEntity());
JSONObject jsonObj = new JSONObject(jsonString);
String sessionId = jsonObj.getString("sessionId")
String requestUrl = "http://localhost:8004/API/License/?sessionId=" + sessionId + "";
// Define the Request Method.
HttpPost requstMethod = new HttpPost(requestUrl);
// Define the Request Body.
StringEntity input =
new StringEntity(
"\"\u003cLicense\u003e\r\n \u003cId\u003e10\u003c/Id\u003e\r\n \u003cLicenseVersion\u003e1\u003c/LicenseVersion\u003e\r\n \u003cLicensee\u003eDundas BI Evaluation User\u003c/Licensee\u003e\r\n \u003cDescription\u003eThe initial Dundas BI license included during deployment.\u003c/Description\u003e\r\n \u003cCpuCoreCount\u003e2147483647\u003c/CpuCoreCount\u003e\r\n \u003cEnabledFeatureIds\u003e\r\n \u003cItem\u003ef36f9244-f363-4f6b-bf54-779d1c0e8123\u003c/Item\u003e\r\n \u003c/EnabledFeatureIds\u003e\r\n \u003cLicenseKind\u003eEvaluation\u003c/LicenseKind\u003e\r\n \u003cProductVersion\u003e4.0\u003c/ProductVersion\u003e\r\n \u003cReleaseKind\u003eAlpha\u003c/ReleaseKind\u003e\r\n \u003cServerCount\u003e100\u003c/ServerCount\u003e\r\n \u003cFloatingPowerUserSeatAllowance\u003e2:0:0\u003c/FloatingPowerUserSeatAllowance\u003e\r\n \u003cFloatingStandardUserSeatAllowance\u003e10:0:0\u003c/FloatingStandardUserSeatAllowance\u003e\r\n \u003cReservedDeveloperSeatAllowance\u003e6:0:0\u003c/ReservedDeveloperSeatAllowance\u003e\r\n \u003cReservedPowerUserSeatAllowance\u003e2:0:0\u003c/ReservedPowerUserSeatAllowance\u003e\r\n \u003cReservedStandardUserSeatAllowance\u003e10:0:0\u003c/ReservedStandardUserSeatAllowance\u003e\r\n \u003cSignature\u003eK5gRAuB70ncH69XQssfZ9U13XvBTtMwJVP+Np8SHBK+QFl70ez1EPPsO2FnbeFYpEZOWdRiL9TntAbAul91rvChGM2/Jj3MwtntkhvNFLvIXkLIk+BnlcLq2xTDVCP4LyyXvZsoz7AeHgCuvAkHdpnXdi8ZIpIfJFrT5KwrpeI9sFFHQBNFFVT/tftBFlp/ppXxsCNT3FofCtKMGqtPwAnnhEpnXZxOPmIHq40n3Yl8m2PsEgFIaJWRCQ2pxT6nrjcGmZuwFr2YhbBMWrsDUf6JshRS2Qh9I4Qn3rBYSHPJ/mSUaFliLqKIOEzBMwEmu9siamK9xoTVNV8iRuXDnGA==\u003c/Signature\u003e\r\n \u003cSignature2\u003ejgJnJwv9hvxeBKGfjwbr2b6g1pvxTHvkVtg2YnABaBYEo/1xafzopWTpj+kRA3UxhK7l0Do1n/jT+rFxd4xMd/N2Yfo7NNyPE1O7OidL3ovKO68NTcBuonJ5EWEsD/jA/Q0AFC/YIMvNlw+54WwzGNLRderpjawelC/Ey+qdusYJEiMD/WnQ+uyRezDpaKlzidFp/W0yufJqp5G/1DxUV78oFO/hW888iq+YGWvubOwIdEXNb9h/kArm0Xx6d1VG+6DZ3WA70xYtX5AJKuQxDGsTR8WZTcBG2EgyEegQWmV2xTFbjIa/TdTwOdLZi7GgRjJRx29ahG09MEjAsXoOKA==\u003c/Signature2\u003e\r\n\u003c/License\u003e\"" );
input.setContentType("application/json");
requstMethod.setEntity(input);
HttpResponse response =
httpClient.execute(requstMethod);
if(response.getStatusLine().getStatusCode() == 200)
{
System.out.println("Success");
}
// The status code indication of success or
// reason of failure.
String json = EntityUtils.toString(response.getEntity());
var baseUrl = 'http://localhost:8005';
var logonOptions =
{
accountName: 'admin',
password: '1234',
cultureName: 'en-us',
deleteOtherSessions: false,
isWindowsLogOn: false
};
$.ajax({
type: 'POST',
url: baseUrl + '/Api/LogOn/',
data: logonOptions,
success: function(logOnResultData) {
var sessionId = logOnResultData.sessionId;
var dataObject = "'\u003cLicense\u003e\r\n \u003cId\u003e10\u003c/Id\u003e\r\n \u003cLicenseVersion\u003e1\u003c/LicenseVersion\u003e\r\n \u003cLicensee\u003eDundas BI Evaluation User\u003c/Licensee\u003e\r\n \u003cDescription\u003eThe initial Dundas BI license included during deployment.\u003c/Description\u003e\r\n \u003cCpuCoreCount\u003e2147483647\u003c/CpuCoreCount\u003e\r\n \u003cEnabledFeatureIds\u003e\r\n \u003cItem\u003ef36f9244-f363-4f6b-bf54-779d1c0e8123\u003c/Item\u003e\r\n \u003c/EnabledFeatureIds\u003e\r\n \u003cLicenseKind\u003eEvaluation\u003c/LicenseKind\u003e\r\n \u003cProductVersion\u003e4.0\u003c/ProductVersion\u003e\r\n \u003cReleaseKind\u003eAlpha\u003c/ReleaseKind\u003e\r\n \u003cServerCount\u003e100\u003c/ServerCount\u003e\r\n \u003cFloatingPowerUserSeatAllowance\u003e2:0:0\u003c/FloatingPowerUserSeatAllowance\u003e\r\n \u003cFloatingStandardUserSeatAllowance\u003e10:0:0\u003c/FloatingStandardUserSeatAllowance\u003e\r\n \u003cReservedDeveloperSeatAllowance\u003e6:0:0\u003c/ReservedDeveloperSeatAllowance\u003e\r\n \u003cReservedPowerUserSeatAllowance\u003e2:0:0\u003c/ReservedPowerUserSeatAllowance\u003e\r\n \u003cReservedStandardUserSeatAllowance\u003e10:0:0\u003c/ReservedStandardUserSeatAllowance\u003e\r\n \u003cSignature\u003eK5gRAuB70ncH69XQssfZ9U13XvBTtMwJVP+Np8SHBK+QFl70ez1EPPsO2FnbeFYpEZOWdRiL9TntAbAul91rvChGM2/Jj3MwtntkhvNFLvIXkLIk+BnlcLq2xTDVCP4LyyXvZsoz7AeHgCuvAkHdpnXdi8ZIpIfJFrT5KwrpeI9sFFHQBNFFVT/tftBFlp/ppXxsCNT3FofCtKMGqtPwAnnhEpnXZxOPmIHq40n3Yl8m2PsEgFIaJWRCQ2pxT6nrjcGmZuwFr2YhbBMWrsDUf6JshRS2Qh9I4Qn3rBYSHPJ/mSUaFliLqKIOEzBMwEmu9siamK9xoTVNV8iRuXDnGA==\u003c/Signature\u003e\r\n \u003cSignature2\u003ejgJnJwv9hvxeBKGfjwbr2b6g1pvxTHvkVtg2YnABaBYEo/1xafzopWTpj+kRA3UxhK7l0Do1n/jT+rFxd4xMd/N2Yfo7NNyPE1O7OidL3ovKO68NTcBuonJ5EWEsD/jA/Q0AFC/YIMvNlw+54WwzGNLRderpjawelC/Ey+qdusYJEiMD/WnQ+uyRezDpaKlzidFp/W0yufJqp5G/1DxUV78oFO/hW888iq+YGWvubOwIdEXNb9h/kArm0Xx6d1VG+6DZ3WA70xYtX5AJKuQxDGsTR8WZTcBG2EgyEegQWmV2xTFbjIa/TdTwOdLZi7GgRjJRx29ahG09MEjAsXoOKA==\u003c/Signature2\u003e\r\n\u003c/License\u003e'";
$.ajax({
type: "POST",
url: baseUrl + "/API/License/?sessionId=" + sessionId + "",
data: dataObject,
dataType:"json",
contentType: "application/json; charset=utf-8",
success: function(data) {
// data = The status code indication of
// success or reason of failure.
},
error: function(data) { alert('failed' + data); }
});
}
});