Dividend#
Allows you to generate a dividend report for a given dividend.
Endpoints:#
GET Dividend/GetList#
Description:
Retrieves a list of dividends.
Query Parameters:
customerIssuerId
integer
Required
Nullable
The unique identifier of the customer issuer.
isPDF
boolean
Optional
Non-nullable
Generates a PDF.
true
= generates a downloadable pdf.
false
= does not generate a downloadable pdf.
Example Request:✓
curl --silent --location '{{baseurl}}/api/v1/Dividend/GetList?customerIssuerId=1' \
--header 'Authorization: Bearer <YOUR TOKEN>'
#!/bin/bash
# Retrieve credentials from environment variables
CLIENT_ID="${SOLO_CLIENT_ID}"
CLIENT_SECRET="${SOLO_CLIENT_SECRET}"
# Define the OAuth2 Token Endpoint
TOKEN_ENDPOINT="{{baseurl}}/connect/token"
# Make a POST request to get the access token
TOKEN_RESPONSE=$(curl -s -X POST "$TOKEN_ENDPOINT" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=client_credentials" \
-d "client_id=$CLIENT_ID" \
-d "client_secret=$CLIENT_SECRET")
# Extract the access token from the response
ACCESS_TOKEN=$(echo "$TOKEN_RESPONSE" | grep -o '"access_token":"[^"]*"' | cut -d'"' -f4)
# Check if the access token was retrieved successfully
if [ -z "$ACCESS_TOKEN" ]; then
echo "Error: Failed to retrieve access token"
echo "$TOKEN_RESPONSE"
exit 1
fi
# Define the API endpoint
API_ENDPOINT="{{baseurl}}/api/v1/Dividend/GetList"
# Make the API request to GetList endpoint
API_RESPONSE=$(curl -s -X GET "$API_ENDPOINT?customerIssuerId=1" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Content-Type: application/json")
# Print the JSON response from the API
echo "$API_RESPONSE"
import os
import requests
# Set up environment variables
client_id = os.environ.get("SOLO_CLIENT_ID")
client_secret = os.environ.get("SOLO_CLIENT_SECRET")
# Define the OAuth2 Token Endpoint
token_url = "{{baseurl}}/connect/token"
# Prepare the Token Request Data
token_data = {
"grant_type": "client_credentials",
"client_id": client_id,
"client_secret": client_secret
}
# Make a POST Request to get token
token_response = requests.post(token_url, data=token_data)
# Handle the Response
if token_response.status_code == 200:
access_token = token_response.json().get("access_token")
# Make the API Request
api_url = "{{baseurl}}/api/v1/Dividend/GetList"
headers = {
"Authorization": f"Bearer {access_token}",
"Content-Type": "application/json"
}
params = {
"customerIssuerId": 1
}
api_response = requests.get(api_url, headers=headers, params=params)
# Print the Response
print(api_response.json())
else:
print(f"Error getting token: {token_response.status_code} - {token_response.text}")
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text.Json;
using System.Threading.Tasks;
class Program
{
static async Task Main(string[] args)
{
// Set up environment variables
string clientId = Environment.GetEnvironmentVariable("SOLO_CLIENT_ID");
string clientSecret = Environment.GetEnvironmentVariable("SOLO_CLIENT_SECRET");
if (string.IsNullOrEmpty(clientId) || string.IsNullOrEmpty(clientSecret))
{
Console.WriteLine("Error: SOLO_CLIENT_ID and SOLO_CLIENT_SECRET environment variables must be set.");
return;
}
// Define the OAuth2 Token Endpoint
string tokenEndpoint = "{{baseurl}}/connect/token";
using HttpClient httpClient = new HttpClient();
// Prepare the Token Request Data
var tokenRequestData = new Dictionary<string, string>
{
{ "grant_type", "client_credentials" },
{ "client_id", clientId },
{ "client_secret", clientSecret }
};
// Make a POST Request to get token
var tokenRequestContent = new FormUrlEncodedContent(tokenRequestData);
HttpResponseMessage tokenResponse = await httpClient.PostAsync(tokenEndpoint, tokenRequestContent);
// Handle the Response
if (tokenResponse.StatusCode != System.Net.HttpStatusCode.OK)
{
Console.WriteLine($"Error: Failed to retrieve access token. Status code: {tokenResponse.StatusCode}");
string errorContent = await tokenResponse.Content.ReadAsStringAsync();
Console.WriteLine($"Response: {errorContent}");
return;
}
string tokenResponseContent = await tokenResponse.Content.ReadAsStringAsync();
JsonDocument tokenJson = JsonDocument.Parse(tokenResponseContent);
string accessToken = tokenJson.RootElement.GetProperty("access_token").GetString();
// Make the API Request
string apiBaseUrl = "{{baseurl}}";
string apiEndpoint = "/api/v1/Dividend/GetList";
int customerIssuerId = 1;
string requestUrl = $"{apiBaseUrl}{apiEndpoint}?customerIssuerId={customerIssuerId}";
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
HttpResponseMessage apiResponse = await httpClient.GetAsync(requestUrl);
// Print the Response
string apiResponseContent = await apiResponse.Content.ReadAsStringAsync();
if (apiResponse.StatusCode == System.Net.HttpStatusCode.OK)
{
JsonDocument responseJson = JsonDocument.Parse(apiResponseContent);
string formattedJson = JsonSerializer.Serialize(responseJson, new JsonSerializerOptions { WriteIndented = true });
Console.WriteLine(formattedJson);
}
else
{
Console.WriteLine($"Error: API request failed. Status code: {apiResponse.StatusCode}");
Console.WriteLine($"Response: {apiResponseContent}");
}
}
}
const https = require('https');
const querystring = require('querystring');
// Environment variables
const SOLO_CLIENT_ID = process.env.SOLO_CLIENT_ID;
const SOLO_CLIENT_SECRET = process.env.SOLO_CLIENT_SECRET;
const TOKEN_URL = '{{baseurl}}/connect/token';
const API_BASE_URL = '{{baseurl}}';
function getAccessToken() {
return new Promise((resolve, reject) => {
const tokenData = querystring.stringify({
grant_type: 'client_credentials',
client_id: SOLO_CLIENT_ID,
client_secret: SOLO_CLIENT_SECRET
});
const url = new URL(TOKEN_URL);
const options = {
hostname: url.hostname,
path: url.pathname,
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': Buffer.byteLength(tokenData)
}
};
const req = https.request(options, (res) => {
let data = '';
res.on('data', (chunk) => {
data += chunk;
});
res.on('end', () => {
if (res.statusCode === 200) {
const response = JSON.parse(data);
resolve(response.access_token);
} else {
reject(new Error(`Failed to get access token. Status: ${res.statusCode}, Response: ${data}`));
}
});
});
req.on('error', (error) => {
reject(error);
});
req.write(tokenData);
req.end();
});
}
function getDividendList(accessToken, customerIssuerId) {
return new Promise((resolve, reject) => {
const url = new URL(`${API_BASE_URL}/api/v1/Dividend/GetList`);
url.searchParams.append('customerIssuerId', customerIssuerId);
const options = {
hostname: url.hostname,
path: url.pathname + url.search,
method: 'GET',
headers: {
'Authorization': `Bearer ${accessToken}`,
'Content-Type': 'application/json'
}
};
const req = https.request(options, (res) => {
let data = '';
res.on('data', (chunk) => {
data += chunk;
});
res.on('end', () => {
if (res.statusCode === 200) {
resolve(JSON.parse(data));
} else {
reject(new Error(`API request failed. Status: ${res.statusCode}, Response: ${data}`));
}
});
});
req.on('error', (error) => {
reject(error);
});
req.end();
});
}
async function main() {
try {
// Get access token
const accessToken = await getAccessToken();
console.log('Access token retrieved successfully');
// Call the Dividend/GetList endpoint
const customerIssuerId = 1;
const response = await getDividendList(accessToken, customerIssuerId);
// Print the JSON response
console.log(JSON.stringify(response, null, 2));
} catch (error) {
console.error('Error:', error.message);
}
}
main();
import axios from 'axios';
async function main() {
// Set up environment variables
const clientId = process.env.SOLO_CLIENT_ID;
const clientSecret = process.env.SOLO_CLIENT_SECRET;
if (!clientId || !clientSecret) {
console.error('Error: SOLO_CLIENT_ID and SOLO_CLIENT_SECRET environment variables must be set');
process.exit(1);
}
// Define the OAuth2 Token Endpoint
const tokenEndpoint = '{{baseurl}}/connect/token';
// Prepare the Token Request Data
const tokenData = new URLSearchParams({
grant_type: 'client_credentials',
client_id: clientId,
client_secret: clientSecret,
});
try {
// Make a POST Request to get token
const tokenResponse = await axios.post(tokenEndpoint, tokenData.toString(), {
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
});
// Handle the Response
if (tokenResponse.status === 200) {
const accessToken = tokenResponse.data.access_token;
// Make the API Request
const apiEndpoint = '{{baseurl}}/api/v1/Dividend/GetList';
const apiResponse = await axios.get(apiEndpoint, {
params: {
customerIssuerId: 1,
},
headers: {
'Authorization': `Bearer ${accessToken}`,
'Content-Type': 'application/json',
},
});
// Print the Response
console.log(JSON.stringify(apiResponse.data, null, 2));
} else {
console.error(`Error: Failed to retrieve token. Status code: ${tokenResponse.status}`);
}
} catch (error) {
if (axios.isAxiosError(error)) {
console.error('Error:', error.response?.data || error.message);
} else {
console.error('Error:', error);
}
}
}
main();
const https = require('https');
const querystring = require('querystring');
// Retrieve credentials from environment variables
const clientId = process.env.SOLO_CLIENT_ID;
const clientSecret = process.env.SOLO_CLIENT_SECRET;
// OAuth2 Token Endpoint
const tokenUrl = '{{baseurl}}/connect/token';
// Function to make HTTPS requests
function makeRequest(url, options, postData = null) {
return new Promise((resolve, reject) => {
const urlObj = new URL(url);
const reqOptions = {
hostname: urlObj.hostname,
path: urlObj.pathname + urlObj.search,
method: options.method || 'GET',
headers: options.headers || {}
};
const req = https.request(reqOptions, (res) => {
let data = '';
res.on('data', (chunk) => {
data += chunk;
});
res.on('end', () => {
resolve({
statusCode: res.statusCode,
body: data
});
});
});
req.on('error', (error) => {
reject(error);
});
if (postData) {
req.write(postData);
}
req.end();
});
}
// Function to get access token
async function getAccessToken() {
const tokenData = querystring.stringify({
grant_type: 'client_credentials',
client_id: clientId,
client_secret: clientSecret
});
const response = await makeRequest(tokenUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': Buffer.byteLength(tokenData)
}
}, tokenData);
if (response.statusCode === 200) {
const tokenResponse = JSON.parse(response.body);
return tokenResponse.access_token;
} else {
throw new Error(`Failed to retrieve access token. Status: ${response.statusCode}, Response: ${response.body}`);
}
}
// Function to call the Dividend GetList endpoint
async function getDividendList(accessToken, customerIssuerId) {
const apiUrl = `{{baseurl}}/api/v1/Dividend/GetList?customerIssuerId=${customerIssuerId}`;
const response = await makeRequest(apiUrl, {
method: 'GET',
headers: {
'Authorization': `Bearer ${accessToken}`,
'Content-Type': 'application/json'
}
});
return {
statusCode: response.statusCode,
body: response.body
};
}
// Main execution
async function main() {
try {
// Get access token
console.log('Retrieving access token...');
const accessToken = await getAccessToken();
console.log('Access token retrieved successfully.');
// Call the Dividend GetList endpoint
console.log('Calling Dividend GetList endpoint...');
const customerIssuerId = 1;
const response = await getDividendList(accessToken, customerIssuerId);
// Print the response
if (response.statusCode === 200) {
const jsonResponse = JSON.parse(response.body);
console.log('Response:');
console.log(JSON.stringify(jsonResponse, null, 2));
} else {
console.log(`Error: Status ${response.statusCode}`);
console.log(response.body);
}
} catch (error) {
console.error('Error:', error.message);
}
}
main();
200 Response:
[
{
"dividendId": 2042,
"type": "Cash",
"security": "Preferred",
"payable": "8/20/2018",
"recordDate": "1/11/2019",
"ratio": "1 for $3.00",
"oustandingShares": 250,
"outstandingSharesFormat": "250",
"distributionAmount": 750,
"distributionAmountFormat": "$750.00",
"fractionalType": "Rounded Down",
"cashPerShare": null,
"cashPerShareFormat": ""
},
{
"dividendId": 4055,
"type": "Stock",
"security": "Common",
"payable": "3/24/2020",
"recordDate": "3/24/2020",
"ratio": "1 for 1.6434",
"oustandingShares": 6463100,
"outstandingSharesFormat": "6,463,100",
"distributionAmount": 10621438,
"distributionAmountFormat": "10,621,438",
"fractionalType": "Pay in Cash",
"cashPerShare": 2,
"cashPerShareFormat": "$2.00"
}
]
POST Dividend/GenerateDividendDetails#
Description:
Generates a detailed report for a given dividend.
Request Body:
dividendId
integer
Required
Non-nullable
SOLO System Dividend/Control Id
isPDF
boolean
Optional
Non-nullable
Generates a PDF.
true
= generates a downloadable pdf.
false
= does not generate a downloadable pdf.
Example Request:✓
curl --silent --location --request POST '{{baseurl}}/api/v1/Dividend/GenerateDividendDetails' \
--header 'Authorization: Bearer <YOUR TOKEN>' \
--header 'Content-Type: application/json' \
--data '{"dividendId": 1}'
#!/bin/bash
# Set up environment variables (these should be set in your environment)
# export SOLO_CLIENT_ID="your_client_id"
# export SOLO_CLIENT_SECRET="your_client_secret"
# Retrieve credentials from environment variables
CLIENT_ID="${SOLO_CLIENT_ID}"
CLIENT_SECRET="${SOLO_CLIENT_SECRET}"
# Check if credentials are set
if [ -z "$CLIENT_ID" ] || [ -z "$CLIENT_SECRET" ]; then
echo "Error: SOLO_CLIENT_ID and SOLO_CLIENT_SECRET environment variables must be set"
exit 1
fi
# Define the OAuth2 Token Endpoint
TOKEN_ENDPOINT="{{baseurl}}/connect/token"
# Make a POST request to get the access token
TOKEN_RESPONSE=$(curl -s -w "\n%{http_code}" -X POST "$TOKEN_ENDPOINT" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=client_credentials" \
-d "client_id=$CLIENT_ID" \
-d "client_secret=$CLIENT_SECRET")
# Extract the HTTP status code (last line)
HTTP_STATUS=$(echo "$TOKEN_RESPONSE" | tail -n 1)
# Extract the response body (all but last line)
TOKEN_BODY=$(echo "$TOKEN_RESPONSE" | sed '$d')
# Handle the response
if [ "$HTTP_STATUS" -eq 200 ]; then
# Extract the access token from the response
ACCESS_TOKEN=$(echo "$TOKEN_BODY" | grep -o '"access_token":"[^"]*"' | cut -d'"' -f4)
if [ -z "$ACCESS_TOKEN" ]; then
echo "Error: Failed to extract access token from response"
echo "Response: $TOKEN_BODY"
exit 1
fi
echo "Successfully obtained access token"
else
echo "Error: Failed to obtain access token"
echo "HTTP Status: $HTTP_STATUS"
echo "Response: $TOKEN_BODY"
exit 1
fi
# Define the API endpoint
API_ENDPOINT="{{baseurl}}/api/v1/Dividend/GenerateDividendDetails"
# Prepare the request body
REQUEST_BODY='{
"dividendId": 1,
"isPDF": false
}'
# Make the API request
echo "Calling GenerateDividendDetails endpoint..."
API_RESPONSE=$(curl -s -X POST "$API_ENDPOINT" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d "$REQUEST_BODY")
# Print the JSON response from the API
echo "API Response:"
echo "$API_RESPONSE"
import os
import requests
# Set up environment variables
client_id = os.environ.get("SOLO_CLIENT_ID")
client_secret = os.environ.get("SOLO_CLIENT_SECRET")
# Define the OAuth2 Token Endpoint
token_url = "{{baseurl}}/connect/token"
# Prepare the Token Request Data
token_data = {
"grant_type": "client_credentials",
"client_id": client_id,
"client_secret": client_secret
}
# Make a POST Request to get token
token_response = requests.post(token_url, data=token_data)
# Handle the Response
if token_response.status_code == 200:
access_token = token_response.json().get("access_token")
# Make the API Request
api_url = "{{baseurl}}/api/v1/Dividend/GenerateDividendDetails"
headers = {
"Authorization": f"Bearer {access_token}",
"Content-Type": "application/json"
}
# Request body from curl example
request_body = {
"dividendId": 1,
"isPDF": False
}
api_response = requests.post(api_url, headers=headers, json=request_body)
# Print the Response
print(api_response.json())
else:
print(f"Error getting token: {token_response.status_code} - {token_response.text}")
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
class Program
{
static async Task Main(string[] args)
{
// Set up environment variables
string clientId = Environment.GetEnvironmentVariable("SOLO_CLIENT_ID");
string clientSecret = Environment.GetEnvironmentVariable("SOLO_CLIENT_SECRET");
if (string.IsNullOrEmpty(clientId) || string.IsNullOrEmpty(clientSecret))
{
Console.WriteLine("Error: SOLO_CLIENT_ID and SOLO_CLIENT_SECRET environment variables must be set.");
return;
}
// Define the OAuth2 Token Endpoint
string tokenEndpoint = "{{baseurl}}/connect/token";
using HttpClient httpClient = new HttpClient();
// Prepare the Token Request Data
var tokenRequestData = new FormUrlEncodedContent(new[]
{
new KeyValuePair<string, string>("grant_type", "client_credentials"),
new KeyValuePair<string, string>("client_id", clientId),
new KeyValuePair<string, string>("client_secret", clientSecret)
});
// Make a POST Request to get token
HttpResponseMessage tokenResponse = await httpClient.PostAsync(tokenEndpoint, tokenRequestData);
// Handle the Response
if (tokenResponse.StatusCode != System.Net.HttpStatusCode.OK)
{
Console.WriteLine($"Error: Failed to retrieve access token. Status code: {tokenResponse.StatusCode}");
string errorContent = await tokenResponse.Content.ReadAsStringAsync();
Console.WriteLine($"Response: {errorContent}");
return;
}
string tokenResponseContent = await tokenResponse.Content.ReadAsStringAsync();
JsonDocument tokenJson = JsonDocument.Parse(tokenResponseContent);
string accessToken = tokenJson.RootElement.GetProperty("access_token").GetString();
Console.WriteLine("Access token retrieved successfully.");
// Make the API Request
string apiEndpoint = "{{baseurl}}/api/v1/Dividend/GenerateDividendDetails";
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
var requestBody = new
{
dividendId = 1,
isPDF = false
};
string jsonRequestBody = JsonSerializer.Serialize(requestBody);
StringContent content = new StringContent(jsonRequestBody, Encoding.UTF8, "application/json");
HttpResponseMessage apiResponse = await httpClient.PostAsync(apiEndpoint, content);
// Print the Response
string apiResponseContent = await apiResponse.Content.ReadAsStringAsync();
if (apiResponse.StatusCode == System.Net.HttpStatusCode.OK)
{
Console.WriteLine("API Response:");
try
{
JsonDocument responseJson = JsonDocument.Parse(apiResponseContent);
Console.WriteLine(JsonSerializer.Serialize(responseJson.RootElement, new JsonSerializerOptions { WriteIndented = true }));
}
catch
{
Console.WriteLine(apiResponseContent);
}
}
else
{
Console.WriteLine($"Error: API request failed. Status code: {apiResponse.StatusCode}");
Console.WriteLine($"Response: {apiResponseContent}");
}
}
}
const https = require('https');
// Environment variables
const clientId = process.env.SOLO_CLIENT_ID;
const clientSecret = process.env.SOLO_CLIENT_SECRET;
// Token endpoint
const tokenUrl = '{{baseurl}}/connect/token';
// Function to make HTTPS request
function makeRequest(url, options, data = null) {
return new Promise((resolve, reject) => {
const urlObj = new URL(url);
const requestOptions = {
hostname: urlObj.hostname,
path: urlObj.pathname + urlObj.search,
method: options.method || 'GET',
headers: options.headers || {}
};
const req = https.request(requestOptions, (res) => {
let body = '';
res.on('data', (chunk) => {
body += chunk;
});
res.on('end', () => {
resolve({
statusCode: res.statusCode,
body: body
});
});
});
req.on('error', (e) => {
reject(e);
});
if (data) {
req.write(data);
}
req.end();
});
}
// Function to get access token
async function getAccessToken() {
const tokenData = new URLSearchParams({
grant_type: 'client_credentials',
client_id: clientId,
client_secret: clientSecret
}).toString();
const response = await makeRequest(tokenUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
}, tokenData);
if (response.statusCode === 200) {
const tokenResponse = JSON.parse(response.body);
return tokenResponse.access_token;
} else {
console.error('Error getting access token:', response.body);
throw new Error('Failed to retrieve access token');
}
}
// Function to call GenerateDividendDetails endpoint
async function generateDividendDetails(accessToken) {
const apiUrl = '{{baseurl}}/api/v1/Dividend/GenerateDividendDetails';
const requestBody = JSON.stringify({
dividendId: 1,
isPDF: false
});
const response = await makeRequest(apiUrl, {
method: 'POST',
headers: {
'Authorization': `Bearer ${accessToken}`,
'Content-Type': 'application/json'
}
}, requestBody);
return JSON.parse(response.body);
}
// Main execution
async function main() {
try {
// Get access token
const accessToken = await getAccessToken();
console.log('Access token retrieved successfully');
// Call the API endpoint
const result = await generateDividendDetails(accessToken);
console.log('API Response:');
console.log(JSON.stringify(result, null, 2));
} catch (error) {
console.error('Error:', error.message);
}
}
main();
import axios from 'axios';
async function main() {
// Set up environment variables
const clientId = process.env.SOLO_CLIENT_ID;
const clientSecret = process.env.SOLO_CLIENT_SECRET;
if (!clientId || !clientSecret) {
console.error('Error: SOLO_CLIENT_ID and SOLO_CLIENT_SECRET environment variables must be set');
process.exit(1);
}
// Define the OAuth2 Token Endpoint
const tokenEndpoint = '{{baseurl}}/connect/token';
// Prepare the Token Request Data
const tokenData = new URLSearchParams({
grant_type: 'client_credentials',
client_id: clientId,
client_secret: clientSecret,
});
try {
// Make a POST Request to get token
const tokenResponse = await axios.post(tokenEndpoint, tokenData.toString(), {
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
});
// Handle the Response
if (tokenResponse.status === 200) {
const accessToken = tokenResponse.data.access_token;
// Make the API Request
const apiEndpoint = '{{baseurl}}/api/v1/Dividend/GenerateDividendDetails';
const requestBody = {
dividendId: 1,
isPDF: false,
};
const apiResponse = await axios.post(apiEndpoint, requestBody, {
headers: {
'Authorization': `Bearer ${accessToken}`,
'Content-Type': 'application/json',
},
});
// Print the Response
console.log(JSON.stringify(apiResponse.data, null, 2));
} else {
console.error(`Error: Failed to retrieve token. Status code: ${tokenResponse.status}`);
}
} catch (error) {
if (axios.isAxiosError(error)) {
console.error('Error:', error.response?.status, error.response?.data || error.message);
} else {
console.error('Error:', error);
}
}
}
main();
const https = require('https');
// Environment variables
const clientId = process.env.SOLO_CLIENT_ID;
const clientSecret = process.env.SOLO_CLIENT_SECRET;
// Token endpoint
const tokenUrl = '{{baseurl}}/connect/token';
// Function to make HTTPS request
function makeRequest(url, options, data = null) {
return new Promise((resolve, reject) => {
const urlObj = new URL(url);
const requestOptions = {
hostname: urlObj.hostname,
path: urlObj.pathname + urlObj.search,
method: options.method || 'GET',
headers: options.headers || {}
};
const req = https.request(requestOptions, (res) => {
let body = '';
res.on('data', (chunk) => body += chunk);
res.on('end', () => {
resolve({
statusCode: res.statusCode,
body: body
});
});
});
req.on('error', reject);
if (data) {
req.write(data);
}
req.end();
});
}
async function main() {
// Prepare token request data
const tokenData = new URLSearchParams({
grant_type: 'client_credentials',
client_id: clientId,
client_secret: clientSecret
}).toString();
// Get access token
const tokenResponse = await makeRequest(tokenUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
}, tokenData);
if (tokenResponse.statusCode !== 200) {
console.error('Error getting token:', tokenResponse.body);
return;
}
const tokenResult = JSON.parse(tokenResponse.body);
const accessToken = tokenResult.access_token;
// Prepare API request data
const requestBody = JSON.stringify({
dividendId: 1,
isPDF: false
});
// Make API request to GenerateDividendDetails
const apiUrl = '{{baseurl}}/api/v1/Dividend/GenerateDividendDetails';
const apiResponse = await makeRequest(apiUrl, {
method: 'POST',
headers: {
'Authorization': `Bearer ${accessToken}`,
'Content-Type': 'application/json'
}
}, requestBody);
// Print the response
if (apiResponse.statusCode === 200) {
const result = JSON.parse(apiResponse.body);
console.log(JSON.stringify(result, null, 2));
} else {
console.error('API Error:', apiResponse.statusCode, apiResponse.body);
}
}
main().catch(console.error);
200 Response:
{
"downloadUrl": "{{baseurl}}/Api/v1/Report/DownloadReport/CfDJ8G2a_F-j-rtGiUBjbT5isV0jFreDl552uI6YQ5enntFyUqg4WgDtMO56PfG50Xk9e_wz9a-38A-nBKdxZvJSz5vM_ZAoTdzvM5mqfRch1N-YGT5ErhQ1yQpYRbGdXS2_VB4Uw_JBLLmaZsyCWZMC4WObnXnlCIOGzAFtBMuFs6AT/dividend-4059.pdf/CfDJ8G2a_F-j-rtGiUBjbT5isV30kJSZsZcu3cvfJwPljBGj-yrKmvV4Z6EiH0tssHVmtnfQ2omDWfnWJdzZ88wBe9KOGS6qS5GJdFzwt3fa2-T9Gd6YpF7pscWQvREwSOyep2YnaWtm-dXP_eHyM-8FVvo"
}