Shareholder#
Resource and endpoints for Shareholder related operations.
Endpoints:#
POST Shareholder/CreateOrUpdate UPDATED
GET Shareholder/Details UPDATED
POST Shareholder/CreateOrUpdate#
Description:
Create a new Shareholder, or
Update an existing Shareholder.
Query Parameters:
idempotencyId
is submitted again, the system will return a
409 Conflict
response.
None = No specific account type.
JointTenant = Joint Tenant account.
TenantsInCommon = Tenants in Common account.
JointWithRightOfSurvivorship = Joint Account with Right of Survivorship.
Trust = Trust account.
CustodyForAMinor = Custody for a Minor account.
CustodyForTheBenefitOf = Custody for the Benefit Of account.
Individual = Individual account.
Corporation = Corporation account.
Partnership = Partnership account.
UnclaimedProperty = Unclaimed Property account.
CommunityProperty = Community Property account.
IRA = Individual Retirement Account.
ProfitSharingOrKeoghPlan = Profit Sharing or Keogh Plan account.
NomineeOrDepository = Nominee or Depository account.
SchoolsAndColleges = Schools and Colleges account.
Plan401K = 401(k) Plan account.
TransferOnDeath = Transfer on Death account.
Custodian = Custodian account.
RetirementAccounts = Retirement Accounts.
SimplifiedEmployeePension = Simplified Employee Pension account.
RothIRA = Roth IRA account.
Pensions = Pensions account.
Example Request:✓
curl --silent --location --request POST '{{baseurl}}/api/v1/Shareholder/CreateOrUpdate' \
--header 'Authorization: Bearer <YOUR TOKEN>' \
--header 'Content-Type: application/json' \
--data '{
"idempotencyId": "738058275223", // NEW
"customerIssuerId": 1,
"firstName": "John",
"lastName": "Doe"
}'
#!/bin/bash
# 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"
# Prepare and make the token request
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 HTTP status code and response body
HTTP_STATUS=$(echo "$TOKEN_RESPONSE" | tail -n 1)
RESPONSE_BODY=$(echo "$TOKEN_RESPONSE" | sed '$d')
# Handle the token response
if [ "$HTTP_STATUS" -eq 200 ]; then
# Extract the access token from the response
ACCESS_TOKEN=$(echo "$RESPONSE_BODY" | grep -o '"access_token":"[^"]*"' | cut -d'"' -f4)
if [ -z "$ACCESS_TOKEN" ]; then
echo "Error: Failed to extract access token from response"
exit 1
fi
echo "Successfully obtained access token"
else
echo "Error: Failed to obtain access token. HTTP Status: $HTTP_STATUS"
echo "Response: $RESPONSE_BODY"
exit 1
fi
# Define the API endpoint
API_ENDPOINT="{{baseurl}}/api/v1/Shareholder/CreateOrUpdate"
# Make the API request
API_RESPONSE=$(curl -s -X POST "$API_ENDPOINT" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"idempotencyId": "738058275223", // NEW
"customerIssuerId": 1,
"firstName": "John",
"lastName": "Doe"
}')
# 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_endpoint = "{{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_endpoint, 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/Shareholder/CreateOrUpdate"
headers = {
"Authorization": f"Bearer {access_token}",
"Content-Type": "application/json"
}
data = {
"idempotencyId": "738058275223", # NEW
"customerIssuerId": 1,
"firstName": "John",
"lastName": "Doe",
}
api_response = requests.post(api_url, headers=headers, json=data)
# Print the Response
print(api_response.json())
else:
print(f"Error retrieving 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 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);
string accessToken = null;
// Handle the response
if (tokenResponse.StatusCode == System.Net.HttpStatusCode.OK)
{
string tokenResponseBody = await tokenResponse.Content.ReadAsStringAsync();
JsonDocument tokenJson = JsonDocument.Parse(tokenResponseBody);
accessToken = tokenJson.RootElement.GetProperty("access_token").GetString();
}
else
{
Console.WriteLine($"Error retrieving token: {tokenResponse.StatusCode}");
string errorBody = await tokenResponse.Content.ReadAsStringAsync();
Console.WriteLine(errorBody);
return;
}
// Make the API request
string apiEndpoint = "{{baseurl}}/api/v1/Shareholder/CreateOrUpdate";
var requestBody = new { idempotencyId = "738058275223", customerIssuerId = 1, firstName = "John", lastName = "Doe" }; // idempotencyId is NEW
var jsonContent = new StringContent(
JsonSerializer.Serialize(requestBody),
Encoding.UTF8,
"application/json");
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
HttpResponseMessage apiResponse = await httpClient.PostAsync(apiEndpoint, jsonContent);
// Print the response
string apiResponseBody = await apiResponse.Content.ReadAsStringAsync();
if (apiResponse.StatusCode == System.Net.HttpStatusCode.OK)
{
JsonDocument jsonResponse = JsonDocument.Parse(apiResponseBody);
string formattedJson = JsonSerializer.Serialize(jsonResponse, new JsonSerializerOptions { WriteIndented = true });
Console.WriteLine(formattedJson);
}
else
{
Console.WriteLine($"API Error: {apiResponse.StatusCode}");
Console.WriteLine(apiResponseBody);
}
}
}
const https = require('https');
const http = require('http');
const { URL } = require('url');
// Retrieve credentials from environment variables
const clientId = process.env.SOLO_CLIENT_ID;
const clientSecret = process.env.SOLO_CLIENT_SECRET;
// Define the OAuth2 Token Endpoint
const tokenEndpoint = '{{baseurl}}/connect/token';
// Function to make HTTP requests
function makeRequest(url, options, postData = null) {
return new Promise((resolve, reject) => {
const parsedUrl = new URL(url);
const protocol = parsedUrl.protocol === 'https:' ? https : http;
const req = protocol.request(url, options, (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();
});
}
async function main() {
// Prepare the Token Request Data
const tokenData = new URLSearchParams({
grant_type: 'client_credentials',
client_id: clientId,
client_secret: clientSecret
}).toString();
// Make a POST request to get token
const tokenOptions = {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': Buffer.byteLength(tokenData)
}
};
try {
const tokenResponse = await makeRequest(tokenEndpoint, tokenOptions, tokenData);
// Handle the Response
if (tokenResponse.statusCode !== 200) {
console.error('Error getting token:', tokenResponse.body);
return;
}
const tokenJson = JSON.parse(tokenResponse.body);
const accessToken = tokenJson.access_token;
// Make the API Request
const apiUrl = '{{baseurl}}/api/v1/Shareholder/CreateOrUpdate';
const requestBody = JSON.stringify({
"idempotencyId": "738058275223", // NEW
"customerIssuerId": 1,
"firstName": "John",
"lastName": "Doe"
});
const apiOptions = {
method: 'POST',
headers: {
'Authorization': `Bearer ${accessToken}`,
'Content-Type': 'application/json',
'Content-Length': Buffer.byteLength(requestBody)
}
};
const apiResponse = await makeRequest(apiUrl, apiOptions, requestBody);
// Print the Response
if (apiResponse.statusCode === 200) {
const responseJson = JSON.parse(apiResponse.body);
console.log(JSON.stringify(responseJson, null, 2));
} else {
console.error('API Error:', apiResponse.statusCode, apiResponse.body);
}
} catch (error) {
console.error('Request failed:', error.message);
}
}
main();
import axios from 'axios';
const SOLO_CLIENT_ID = process.env.SOLO_CLIENT_ID;
const SOLO_CLIENT_SECRET = process.env.SOLO_CLIENT_SECRET;
const BASE_URL = '{{baseurl}}';
const TOKEN_ENDPOINT = `${BASE_URL}/connect/token`;
async function getAccessToken(): Promise<string | null> {
const tokenRequestData = new URLSearchParams({
grant_type: 'client_credentials',
client_id: SOLO_CLIENT_ID || '',
client_secret: SOLO_CLIENT_SECRET || ''
});
try {
const response = await axios.post(TOKEN_ENDPOINT, tokenRequestData, {
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
});
if (response.status === 200) {
return response.data.access_token;
} else {
console.error('Error retrieving token:', response.status, response.statusText);
return null;
}
} catch (error) {
console.error('Error retrieving token:', error);
return null;
}
}
async function callCreateOrUpdate(accessToken: string): Promise<void> {
const apiEndpoint = `${BASE_URL}/api/v1/Shareholder/CreateOrUpdate`;
try {
const requestBody = { idempotencyId: "738058275223", customerIssuerId: 1, firstName: "John", lastName: "Doe" }; // idempotencyId is NEW
const response = await axios.post(apiEndpoint, requestBody, {
headers: {
'Authorization': `Bearer ${accessToken}`,
'Content-Type': 'application/json'
}
});
console.log(JSON.stringify(response.data, null, 2));
} catch (error) {
console.error('Error calling API:', error);
}
}
async function main(): Promise<void> {
if (!SOLO_CLIENT_ID || !SOLO_CLIENT_SECRET) {
console.error('Please set SOLO_CLIENT_ID and SOLO_CLIENT_SECRET environment variables');
return;
}
const accessToken = await getAccessToken();
if (accessToken) {
await callCreateOrUpdate(accessToken);
} else {
console.error('Failed to obtain access token');
}
}
main();
const https = require('https');
const http = require('http');
const { URL } = require('url');
// Retrieve credentials from environment variables
const clientId = process.env.SOLO_CLIENT_ID;
const clientSecret = process.env.SOLO_CLIENT_SECRET;
// Define the OAuth2 Token Endpoint
const tokenEndpoint = '{{baseurl}}/connect/token';
// Function to make HTTP requests
function makeRequest(url, options, postData = null) {
return new Promise((resolve, reject) => {
const parsedUrl = new URL(url);
const protocol = parsedUrl.protocol === 'https:' ? https : http;
const req = protocol.request(url, options, (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();
});
}
async function main() {
// Prepare the Token Request Data
const tokenData = new URLSearchParams({
grant_type: 'client_credentials',
client_id: clientId,
client_secret: clientSecret
}).toString();
// Make a POST request to get token
const tokenOptions = {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': Buffer.byteLength(tokenData)
}
};
try {
const tokenResponse = await makeRequest(tokenEndpoint, tokenOptions, tokenData);
// Handle the Response
if (tokenResponse.statusCode !== 200) {
console.error('Error getting token:', tokenResponse.body);
return;
}
const tokenJson = JSON.parse(tokenResponse.body);
const accessToken = tokenJson.access_token;
// Make the API Request
const apiUrl = '{{baseurl}}/api/v1/Shareholder/CreateOrUpdate';
const requestBody = JSON.stringify({
"idempotencyId": "738058275223", // NEW
"customerIssuerId": 1,
"firstName": "John",
"lastName": "Doe"
});
const apiOptions = {
method: 'POST',
headers: {
'Authorization': `Bearer ${accessToken}`,
'Content-Type': 'application/json',
'Content-Length': Buffer.byteLength(requestBody)
}
};
const apiResponse = await makeRequest(apiUrl, apiOptions, requestBody);
// Print the Response
if (apiResponse.statusCode === 200) {
const responseJson = JSON.parse(apiResponse.body);
console.log(JSON.stringify(responseJson, null, 2));
} else {
console.error('API Error:', apiResponse.statusCode, apiResponse.body);
}
} catch (error) {
console.error('Request failed:', error.message);
}
}
main();
200 Response:
{
"action": "Update",
"customerShareholderId": "Shrhld-00001",
"systemShareholderId": 28599
}
409 Response (Duplicate Request):
{
"message": "Duplicate request detected. The idempotencyId has already been used.", // New
"idempotencyId": "738058275223" // New
}
GET Shareholder/Details#
Description:
Retrieves detailed information about specified Shareholder.
Query Parameters:
Example Request:✓
curl --silent --location '{{baseurl}}/api/v1/Shareholder/Details?CustomerShareholderId=T5914714658&SystemShareholderId=0' \
--header 'Authorization: Bearer <YOUR TOKEN>'
#!/bin/bash
# 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"
# Prepare and make the token request
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 HTTP status code and response body
HTTP_STATUS=$(echo "$TOKEN_RESPONSE" | tail -n 1)
RESPONSE_BODY=$(echo "$TOKEN_RESPONSE" | sed '$d')
# Handle the token response
if [ "$HTTP_STATUS" -eq 200 ]; then
# Extract the access token from the response
ACCESS_TOKEN=$(echo "$RESPONSE_BODY" | grep -o '"access_token":"[^"]*"' | cut -d'"' -f4)
if [ -z "$ACCESS_TOKEN" ]; then
echo "Error: Failed to extract access token from response"
exit 1
fi
echo "Successfully obtained access token"
else
echo "Error: Failed to obtain access token. HTTP Status: $HTTP_STATUS"
echo "Response: $RESPONSE_BODY"
exit 1
fi
# Define the API endpoint
API_ENDPOINT="{{baseurl}}/api/v1/Shareholder/Details"
# Make the API request
API_RESPONSE=$(curl -s -X GET "$API_ENDPOINT?CustomerShareholderId=T5914714658&SystemShareholderId=0" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Content-Type: application/json")
# 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_endpoint = "{{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_endpoint, 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/Shareholder/Details"
headers = {
"Authorization": f"Bearer {access_token}",
"Content-Type": "application/json"
}
params = {
"CustomerShareholderId": "T5914714658",
"SystemShareholderId": 0,
}
api_response = requests.get(api_url, headers=headers, params=params)
# Print the Response
print(api_response.json())
else:
print(f"Error retrieving 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 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);
string accessToken = null;
// Handle the response
if (tokenResponse.StatusCode == System.Net.HttpStatusCode.OK)
{
string tokenResponseBody = await tokenResponse.Content.ReadAsStringAsync();
JsonDocument tokenJson = JsonDocument.Parse(tokenResponseBody);
accessToken = tokenJson.RootElement.GetProperty("access_token").GetString();
}
else
{
Console.WriteLine($"Error retrieving token: {tokenResponse.StatusCode}");
string errorBody = await tokenResponse.Content.ReadAsStringAsync();
Console.WriteLine(errorBody);
return;
}
// Make the API request
string apiEndpoint = "{{baseurl}}/api/v1/Shareholder/Details?CustomerShareholderId=T5914714658&SystemShareholderId=0";
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
HttpResponseMessage apiResponse = await httpClient.GetAsync(apiEndpoint);
// Print the response
string apiResponseBody = await apiResponse.Content.ReadAsStringAsync();
if (apiResponse.StatusCode == System.Net.HttpStatusCode.OK)
{
JsonDocument jsonResponse = JsonDocument.Parse(apiResponseBody);
string formattedJson = JsonSerializer.Serialize(jsonResponse, new JsonSerializerOptions { WriteIndented = true });
Console.WriteLine(formattedJson);
}
else
{
Console.WriteLine($"API Error: {apiResponse.StatusCode}");
Console.WriteLine(apiResponseBody);
}
}
}
const https = require('https');
const http = require('http');
const { URL } = require('url');
// Retrieve credentials from environment variables
const clientId = process.env.SOLO_CLIENT_ID;
const clientSecret = process.env.SOLO_CLIENT_SECRET;
// Define the OAuth2 Token Endpoint
const tokenEndpoint = '{{baseurl}}/connect/token';
// Function to make HTTP requests
function makeRequest(url, options, postData = null) {
return new Promise((resolve, reject) => {
const parsedUrl = new URL(url);
const protocol = parsedUrl.protocol === 'https:' ? https : http;
const req = protocol.request(url, options, (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();
});
}
async function main() {
// Prepare the Token Request Data
const tokenData = new URLSearchParams({
grant_type: 'client_credentials',
client_id: clientId,
client_secret: clientSecret
}).toString();
// Make a POST request to get token
const tokenOptions = {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': Buffer.byteLength(tokenData)
}
};
try {
const tokenResponse = await makeRequest(tokenEndpoint, tokenOptions, tokenData);
// Handle the Response
if (tokenResponse.statusCode !== 200) {
console.error('Error getting token:', tokenResponse.body);
return;
}
const tokenJson = JSON.parse(tokenResponse.body);
const accessToken = tokenJson.access_token;
// Make the API Request
const apiUrl = '{{baseurl}}/api/v1/Shareholder/Details?CustomerShareholderId=T5914714658&SystemShareholderId=0';
const apiOptions = {
method: 'GET',
headers: {
'Authorization': `Bearer ${accessToken}`,
'Content-Type': 'application/json'
}
};
const apiResponse = await makeRequest(apiUrl, apiOptions);
// Print the Response
if (apiResponse.statusCode === 200) {
const responseJson = JSON.parse(apiResponse.body);
console.log(JSON.stringify(responseJson, null, 2));
} else {
console.error('API Error:', apiResponse.statusCode, apiResponse.body);
}
} catch (error) {
console.error('Request failed:', error.message);
}
}
main();
import axios from 'axios';
const SOLO_CLIENT_ID = process.env.SOLO_CLIENT_ID;
const SOLO_CLIENT_SECRET = process.env.SOLO_CLIENT_SECRET;
const BASE_URL = '{{baseurl}}';
const TOKEN_ENDPOINT = `${BASE_URL}/connect/token`;
async function getAccessToken(): Promise<string | null> {
const tokenRequestData = new URLSearchParams({
grant_type: 'client_credentials',
client_id: SOLO_CLIENT_ID || '',
client_secret: SOLO_CLIENT_SECRET || ''
});
try {
const response = await axios.post(TOKEN_ENDPOINT, tokenRequestData, {
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
});
if (response.status === 200) {
return response.data.access_token;
} else {
console.error('Error retrieving token:', response.status, response.statusText);
return null;
}
} catch (error) {
console.error('Error retrieving token:', error);
return null;
}
}
async function callDetails(accessToken: string): Promise<void> {
const apiEndpoint = `${BASE_URL}/api/v1/Shareholder/Details`;
try {
const params = { CustomerShareholderId: "T5914714658", SystemShareholderId: 0 };
const response = await axios.get(apiEndpoint, {
headers: {
'Authorization': `Bearer ${accessToken}`,
'Content-Type': 'application/json'
},
params: params
});
console.log(JSON.stringify(response.data, null, 2));
} catch (error) {
console.error('Error calling API:', error);
}
}
async function main(): Promise<void> {
if (!SOLO_CLIENT_ID || !SOLO_CLIENT_SECRET) {
console.error('Please set SOLO_CLIENT_ID and SOLO_CLIENT_SECRET environment variables');
return;
}
const accessToken = await getAccessToken();
if (accessToken) {
await callDetails(accessToken);
} else {
console.error('Failed to obtain access token');
}
}
main();
const https = require('https');
const http = require('http');
const { URL } = require('url');
// Retrieve credentials from environment variables
const clientId = process.env.SOLO_CLIENT_ID;
const clientSecret = process.env.SOLO_CLIENT_SECRET;
// Define the OAuth2 Token Endpoint
const tokenEndpoint = '{{baseurl}}/connect/token';
// Function to make HTTP requests
function makeRequest(url, options, postData = null) {
return new Promise((resolve, reject) => {
const parsedUrl = new URL(url);
const protocol = parsedUrl.protocol === 'https:' ? https : http;
const req = protocol.request(url, options, (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();
});
}
async function main() {
// Prepare the Token Request Data
const tokenData = new URLSearchParams({
grant_type: 'client_credentials',
client_id: clientId,
client_secret: clientSecret
}).toString();
// Make a POST request to get token
const tokenOptions = {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': Buffer.byteLength(tokenData)
}
};
try {
const tokenResponse = await makeRequest(tokenEndpoint, tokenOptions, tokenData);
// Handle the Response
if (tokenResponse.statusCode !== 200) {
console.error('Error getting token:', tokenResponse.body);
return;
}
const tokenJson = JSON.parse(tokenResponse.body);
const accessToken = tokenJson.access_token;
// Make the API Request
const apiUrl = '{{baseurl}}/api/v1/Shareholder/Details?CustomerShareholderId=T5914714658&SystemShareholderId=0';
const apiOptions = {
method: 'GET',
headers: {
'Authorization': `Bearer ${accessToken}`,
'Content-Type': 'application/json'
}
};
const apiResponse = await makeRequest(apiUrl, apiOptions);
// Print the Response
if (apiResponse.statusCode === 200) {
const responseJson = JSON.parse(apiResponse.body);
console.log(JSON.stringify(responseJson, null, 2));
} else {
console.error('API Error:', apiResponse.statusCode, apiResponse.body);
}
} catch (error) {
console.error('Request failed:', error.message);
}
}
main();
200 Response:
{
"sortName": "Doe John",
"customerShareholderId": "23432E",
"systemShareholderId": 13423,
"displayShareholderId": "23432E",
"name": "John Doe",
"fullPrimaryAddress": "123 Demo Street, Portland, OR 97214 United States",
"primaryAddress": {
"address1": "123 Demo Street",
"address2": "",
"city": "Portland",
"state": "OR",
"postalCode": "97214",
"country2Code": "US",
"email": "johndoe@email",
"phone": "53342242",
"secondaryPhone": "",
"country": "United States"
},
"fullMailingAddress": "",
"mailingAddress": null,
"type": "Individual Retirement Account",
"typeEnum": "IRA", // New
"primaryTaxId": "476-34-3433",
"primaryTaxIdType": "SSN",
"primaryPayeeName": "John Doe",
"secondaryTaxId": "",
"secondaryTaxIdType": "",
"secondaryPayeeName": ""
}
GET Shareholder/GetHoldingSummary#
Description:
Retrieves summary of holdings for specified Shareholder.
Query Parameters:
Example Request:✓
curl --silent --location '{{baseurl}}/api/v1/Shareholder/GetHoldingSummary?CustomerShareholderId=T5914714658&SystemShareholderId=0' \
--header 'Authorization: Bearer <YOUR TOKEN>'
#!/bin/bash
# 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"
# Prepare and make the token request
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 HTTP status code and response body
HTTP_STATUS=$(echo "$TOKEN_RESPONSE" | tail -n 1)
RESPONSE_BODY=$(echo "$TOKEN_RESPONSE" | sed '$d')
# Handle the token response
if [ "$HTTP_STATUS" -eq 200 ]; then
# Extract the access token from the response
ACCESS_TOKEN=$(echo "$RESPONSE_BODY" | grep -o '"access_token":"[^"]*"' | cut -d'"' -f4)
if [ -z "$ACCESS_TOKEN" ]; then
echo "Error: Failed to extract access token from response"
exit 1
fi
echo "Successfully obtained access token"
else
echo "Error: Failed to obtain access token. HTTP Status: $HTTP_STATUS"
echo "Response: $RESPONSE_BODY"
exit 1
fi
# Define the API endpoint
API_ENDPOINT="{{baseurl}}/api/v1/Shareholder/GetHoldingSummary"
# Make the API request
API_RESPONSE=$(curl -s -X GET "$API_ENDPOINT?CustomerShareholderId=T5914714658&SystemShareholderId=0" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Content-Type: application/json")
# 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_endpoint = "{{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_endpoint, 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/Shareholder/GetHoldingSummary"
headers = {
"Authorization": f"Bearer {access_token}",
"Content-Type": "application/json"
}
params = {
"CustomerShareholderId": "T5914714658",
"SystemShareholderId": 0,
}
api_response = requests.get(api_url, headers=headers, params=params)
# Print the Response
print(api_response.json())
else:
print(f"Error retrieving 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 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);
string accessToken = null;
// Handle the response
if (tokenResponse.StatusCode == System.Net.HttpStatusCode.OK)
{
string tokenResponseBody = await tokenResponse.Content.ReadAsStringAsync();
JsonDocument tokenJson = JsonDocument.Parse(tokenResponseBody);
accessToken = tokenJson.RootElement.GetProperty("access_token").GetString();
}
else
{
Console.WriteLine($"Error retrieving token: {tokenResponse.StatusCode}");
string errorBody = await tokenResponse.Content.ReadAsStringAsync();
Console.WriteLine(errorBody);
return;
}
// Make the API request
string apiEndpoint = "{{baseurl}}/api/v1/Shareholder/GetHoldingSummary?CustomerShareholderId=T5914714658&SystemShareholderId=0";
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
HttpResponseMessage apiResponse = await httpClient.GetAsync(apiEndpoint);
// Print the response
string apiResponseBody = await apiResponse.Content.ReadAsStringAsync();
if (apiResponse.StatusCode == System.Net.HttpStatusCode.OK)
{
JsonDocument jsonResponse = JsonDocument.Parse(apiResponseBody);
string formattedJson = JsonSerializer.Serialize(jsonResponse, new JsonSerializerOptions { WriteIndented = true });
Console.WriteLine(formattedJson);
}
else
{
Console.WriteLine($"API Error: {apiResponse.StatusCode}");
Console.WriteLine(apiResponseBody);
}
}
}
const https = require('https');
const http = require('http');
const { URL } = require('url');
// Retrieve credentials from environment variables
const clientId = process.env.SOLO_CLIENT_ID;
const clientSecret = process.env.SOLO_CLIENT_SECRET;
// Define the OAuth2 Token Endpoint
const tokenEndpoint = '{{baseurl}}/connect/token';
// Function to make HTTP requests
function makeRequest(url, options, postData = null) {
return new Promise((resolve, reject) => {
const parsedUrl = new URL(url);
const protocol = parsedUrl.protocol === 'https:' ? https : http;
const req = protocol.request(url, options, (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();
});
}
async function main() {
// Prepare the Token Request Data
const tokenData = new URLSearchParams({
grant_type: 'client_credentials',
client_id: clientId,
client_secret: clientSecret
}).toString();
// Make a POST request to get token
const tokenOptions = {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': Buffer.byteLength(tokenData)
}
};
try {
const tokenResponse = await makeRequest(tokenEndpoint, tokenOptions, tokenData);
// Handle the Response
if (tokenResponse.statusCode !== 200) {
console.error('Error getting token:', tokenResponse.body);
return;
}
const tokenJson = JSON.parse(tokenResponse.body);
const accessToken = tokenJson.access_token;
// Make the API Request
const apiUrl = '{{baseurl}}/api/v1/Shareholder/GetHoldingSummary?CustomerShareholderId=T5914714658&SystemShareholderId=0';
const apiOptions = {
method: 'GET',
headers: {
'Authorization': `Bearer ${accessToken}`,
'Content-Type': 'application/json'
}
};
const apiResponse = await makeRequest(apiUrl, apiOptions);
// Print the Response
if (apiResponse.statusCode === 200) {
const responseJson = JSON.parse(apiResponse.body);
console.log(JSON.stringify(responseJson, null, 2));
} else {
console.error('API Error:', apiResponse.statusCode, apiResponse.body);
}
} catch (error) {
console.error('Request failed:', error.message);
}
}
main();
import axios from 'axios';
const SOLO_CLIENT_ID = process.env.SOLO_CLIENT_ID;
const SOLO_CLIENT_SECRET = process.env.SOLO_CLIENT_SECRET;
const BASE_URL = '{{baseurl}}';
const TOKEN_ENDPOINT = `${BASE_URL}/connect/token`;
async function getAccessToken(): Promise<string | null> {
const tokenRequestData = new URLSearchParams({
grant_type: 'client_credentials',
client_id: SOLO_CLIENT_ID || '',
client_secret: SOLO_CLIENT_SECRET || ''
});
try {
const response = await axios.post(TOKEN_ENDPOINT, tokenRequestData, {
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
});
if (response.status === 200) {
return response.data.access_token;
} else {
console.error('Error retrieving token:', response.status, response.statusText);
return null;
}
} catch (error) {
console.error('Error retrieving token:', error);
return null;
}
}
async function callGetHoldingSummary(accessToken: string): Promise<void> {
const apiEndpoint = `${BASE_URL}/api/v1/Shareholder/GetHoldingSummary`;
try {
const params = { CustomerShareholderId: "T5914714658", SystemShareholderId: 0 };
const response = await axios.get(apiEndpoint, {
headers: {
'Authorization': `Bearer ${accessToken}`,
'Content-Type': 'application/json'
},
params: params
});
console.log(JSON.stringify(response.data, null, 2));
} catch (error) {
console.error('Error calling API:', error);
}
}
async function main(): Promise<void> {
if (!SOLO_CLIENT_ID || !SOLO_CLIENT_SECRET) {
console.error('Please set SOLO_CLIENT_ID and SOLO_CLIENT_SECRET environment variables');
return;
}
const accessToken = await getAccessToken();
if (accessToken) {
await callGetHoldingSummary(accessToken);
} else {
console.error('Failed to obtain access token');
}
}
main();
const https = require('https');
const http = require('http');
const { URL } = require('url');
// Retrieve credentials from environment variables
const clientId = process.env.SOLO_CLIENT_ID;
const clientSecret = process.env.SOLO_CLIENT_SECRET;
// Define the OAuth2 Token Endpoint
const tokenEndpoint = '{{baseurl}}/connect/token';
// Function to make HTTP requests
function makeRequest(url, options, postData = null) {
return new Promise((resolve, reject) => {
const parsedUrl = new URL(url);
const protocol = parsedUrl.protocol === 'https:' ? https : http;
const req = protocol.request(url, options, (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();
});
}
async function main() {
// Prepare the Token Request Data
const tokenData = new URLSearchParams({
grant_type: 'client_credentials',
client_id: clientId,
client_secret: clientSecret
}).toString();
// Make a POST request to get token
const tokenOptions = {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': Buffer.byteLength(tokenData)
}
};
try {
const tokenResponse = await makeRequest(tokenEndpoint, tokenOptions, tokenData);
// Handle the Response
if (tokenResponse.statusCode !== 200) {
console.error('Error getting token:', tokenResponse.body);
return;
}
const tokenJson = JSON.parse(tokenResponse.body);
const accessToken = tokenJson.access_token;
// Make the API Request
const apiUrl = '{{baseurl}}/api/v1/Shareholder/GetHoldingSummary?CustomerShareholderId=T5914714658&SystemShareholderId=0';
const apiOptions = {
method: 'GET',
headers: {
'Authorization': `Bearer ${accessToken}`,
'Content-Type': 'application/json'
}
};
const apiResponse = await makeRequest(apiUrl, apiOptions);
// Print the Response
if (apiResponse.statusCode === 200) {
const responseJson = JSON.parse(apiResponse.body);
console.log(JSON.stringify(responseJson, null, 2));
} else {
console.error('API Error:', apiResponse.statusCode, apiResponse.body);
}
} catch (error) {
console.error('Request failed:', error.message);
}
}
main();
200 Response:
[
{
"securityTypeId": 1,
"security": "Common",
"shares": 9,
"sharesFormat": "9",
"numberOfCertificates": 2,
"numberOfCertificatesFormat": "2",
"hasBookCertificates": false
},
{
"securityTypeId": 2,
"security": "Warrant",
"shares": 4,
"sharesFormat": "4",
"numberOfCertificates": 1,
"numberOfCertificatesFormat": "1",
"hasBookCertificates": true
},
{
"securityTypeId": 6,
"security": "Preferred",
"shares": 250,
"sharesFormat": "250",
"numberOfCertificates": 1,
"numberOfCertificatesFormat": "1",
"hasBookCertificates": true
}
]
GET Shareholder/Details/List#
Description:
Retrieves a list of shareholder details.
Query Parameters:
Example Request:✓
curl --silent --location '{{baseurl}}/api/v1/Shareholder/Details/List?CustomerIssuerId=9999' \
--header 'Authorization: Bearer <YOUR TOKEN>'
#!/bin/bash
# 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"
# Prepare and make the token request
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 HTTP status code and response body
HTTP_STATUS=$(echo "$TOKEN_RESPONSE" | tail -n 1)
RESPONSE_BODY=$(echo "$TOKEN_RESPONSE" | sed '$d')
# Handle the token response
if [ "$HTTP_STATUS" -eq 200 ]; then
# Extract the access token from the response
ACCESS_TOKEN=$(echo "$RESPONSE_BODY" | grep -o '"access_token":"[^"]*"' | cut -d'"' -f4)
if [ -z "$ACCESS_TOKEN" ]; then
echo "Error: Failed to extract access token from response"
exit 1
fi
echo "Successfully obtained access token"
else
echo "Error: Failed to obtain access token. HTTP Status: $HTTP_STATUS"
echo "Response: $RESPONSE_BODY"
exit 1
fi
# Define the API endpoint
API_ENDPOINT="{{baseurl}}/api/v1/Shareholder/Details/List"
# Make the API request
API_RESPONSE=$(curl -s -X GET "$API_ENDPOINT?CustomerIssuerId=9999" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Content-Type: application/json")
# Print the JSON response
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_endpoint = "{{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_endpoint, 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/Shareholder/Details/List"
headers = {
"Authorization": f"Bearer {access_token}",
"Content-Type": "application/json"
}
params = {
"CustomerIssuerId": 9999,
}
api_response = requests.get(api_url, headers=headers, params=params)
# Print the Response
print(api_response.json())
else:
print(f"Error retrieving 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 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);
string accessToken = null;
// Handle the response
if (tokenResponse.StatusCode == System.Net.HttpStatusCode.OK)
{
string tokenResponseBody = await tokenResponse.Content.ReadAsStringAsync();
JsonDocument tokenJson = JsonDocument.Parse(tokenResponseBody);
accessToken = tokenJson.RootElement.GetProperty("access_token").GetString();
}
else
{
Console.WriteLine($"Error retrieving token: {tokenResponse.StatusCode}");
string errorBody = await tokenResponse.Content.ReadAsStringAsync();
Console.WriteLine(errorBody);
return;
}
// Make the API request
string apiEndpoint = "{{baseurl}}/api/v1/Shareholder/Details/List?CustomerIssuerId=9999";
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
HttpResponseMessage apiResponse = await httpClient.GetAsync(apiEndpoint);
// Print the response
string apiResponseBody = await apiResponse.Content.ReadAsStringAsync();
if (apiResponse.StatusCode == System.Net.HttpStatusCode.OK)
{
JsonDocument jsonResponse = JsonDocument.Parse(apiResponseBody);
string formattedJson = JsonSerializer.Serialize(jsonResponse, new JsonSerializerOptions { WriteIndented = true });
Console.WriteLine(formattedJson);
}
else
{
Console.WriteLine($"API Error: {apiResponse.StatusCode}");
Console.WriteLine(apiResponseBody);
}
}
}
const https = require('https');
const http = require('http');
const { URL } = require('url');
// Retrieve credentials from environment variables
const clientId = process.env.SOLO_CLIENT_ID;
const clientSecret = process.env.SOLO_CLIENT_SECRET;
// Define the OAuth2 Token Endpoint
const tokenEndpoint = '{{baseurl}}/connect/token';
// Function to make HTTP requests
function makeRequest(url, options, postData = null) {
return new Promise((resolve, reject) => {
const parsedUrl = new URL(url);
const protocol = parsedUrl.protocol === 'https:' ? https : http;
const req = protocol.request(url, options, (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();
});
}
async function main() {
// Prepare the Token Request Data
const tokenData = new URLSearchParams({
grant_type: 'client_credentials',
client_id: clientId,
client_secret: clientSecret
}).toString();
// Make a POST request to get token
const tokenOptions = {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': Buffer.byteLength(tokenData)
}
};
try {
const tokenResponse = await makeRequest(tokenEndpoint, tokenOptions, tokenData);
// Handle the Response
if (tokenResponse.statusCode !== 200) {
console.error('Error getting token:', tokenResponse.body);
return;
}
const tokenJson = JSON.parse(tokenResponse.body);
const accessToken = tokenJson.access_token;
// Make the API Request
const apiUrl = '{{baseurl}}/api/v1/Shareholder/Details/List?CustomerIssuerId=9999';
const apiOptions = {
method: 'GET',
headers: {
'Authorization': `Bearer ${accessToken}`,
'Content-Type': 'application/json'
}
};
const apiResponse = await makeRequest(apiUrl, apiOptions);
// Print the Response
if (apiResponse.statusCode === 200) {
const responseJson = JSON.parse(apiResponse.body);
console.log(JSON.stringify(responseJson, null, 2));
} else {
console.error('API Error:', apiResponse.statusCode, apiResponse.body);
}
} catch (error) {
console.error('Request failed:', error.message);
}
}
main();
import axios from 'axios';
const SOLO_CLIENT_ID = process.env.SOLO_CLIENT_ID;
const SOLO_CLIENT_SECRET = process.env.SOLO_CLIENT_SECRET;
const BASE_URL = '{{baseurl}}';
const TOKEN_ENDPOINT = `${BASE_URL}/connect/token`;
async function getAccessToken(): Promise<string | null> {
const tokenRequestData = new URLSearchParams({
grant_type: 'client_credentials',
client_id: SOLO_CLIENT_ID || '',
client_secret: SOLO_CLIENT_SECRET || ''
});
try {
const response = await axios.post(TOKEN_ENDPOINT, tokenRequestData, {
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
});
if (response.status === 200) {
return response.data.access_token;
} else {
console.error('Error retrieving token:', response.status, response.statusText);
return null;
}
} catch (error) {
console.error('Error retrieving token:', error);
return null;
}
}
async function callDetailsList(accessToken: string): Promise<void> {
const apiEndpoint = `${BASE_URL}/api/v1/Shareholder/Details/List`;
try {
const params = { CustomerIssuerId: 9999 };
const response = await axios.get(apiEndpoint, {
headers: {
'Authorization': `Bearer ${accessToken}`,
'Content-Type': 'application/json'
},
params: params
});
console.log(JSON.stringify(response.data, null, 2));
} catch (error) {
console.error('Error calling API:', error);
}
}
async function main(): Promise<void> {
if (!SOLO_CLIENT_ID || !SOLO_CLIENT_SECRET) {
console.error('Please set SOLO_CLIENT_ID and SOLO_CLIENT_SECRET environment variables');
return;
}
const accessToken = await getAccessToken();
if (accessToken) {
await callDetailsList(accessToken);
} else {
console.error('Failed to obtain access token');
}
}
main();
const https = require('https');
const http = require('http');
const { URL } = require('url');
// Retrieve credentials from environment variables
const clientId = process.env.SOLO_CLIENT_ID;
const clientSecret = process.env.SOLO_CLIENT_SECRET;
// Define the OAuth2 Token Endpoint
const tokenEndpoint = '{{baseurl}}/connect/token';
// Function to make HTTP requests
function makeRequest(url, options, postData = null) {
return new Promise((resolve, reject) => {
const parsedUrl = new URL(url);
const protocol = parsedUrl.protocol === 'https:' ? https : http;
const req = protocol.request(url, options, (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();
});
}
async function main() {
// Prepare the Token Request Data
const tokenData = new URLSearchParams({
grant_type: 'client_credentials',
client_id: clientId,
client_secret: clientSecret
}).toString();
// Make a POST request to get token
const tokenOptions = {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': Buffer.byteLength(tokenData)
}
};
try {
const tokenResponse = await makeRequest(tokenEndpoint, tokenOptions, tokenData);
// Handle the Response
if (tokenResponse.statusCode !== 200) {
console.error('Error getting token:', tokenResponse.body);
return;
}
const tokenJson = JSON.parse(tokenResponse.body);
const accessToken = tokenJson.access_token;
// Make the API Request
const apiUrl = '{{baseurl}}/api/v1/Shareholder/Details/List?CustomerIssuerId=9999';
const apiOptions = {
method: 'GET',
headers: {
'Authorization': `Bearer ${accessToken}`,
'Content-Type': 'application/json'
}
};
const apiResponse = await makeRequest(apiUrl, apiOptions);
// Print the Response
if (apiResponse.statusCode === 200) {
const responseJson = JSON.parse(apiResponse.body);
console.log(JSON.stringify(responseJson, null, 2));
} else {
console.error('API Error:', apiResponse.statusCode, apiResponse.body);
}
} catch (error) {
console.error('Request failed:', error.message);
}
}
main();
200 Response:
{
"shareholders": []
}