Proxy#
Resource and endpoints for proxy related operations.
Endpoints:#
GET Proxy/GetList
GET Proxy/GetList#
Description:
Retrieves a list of proxies.
Query Parameters:
customerIssuerId
integer
Required
Nullable
The unique identifier of the customer issuer.
Example Request:✓
curl --silent --location '{{baseurl}}/api/v1/Proxy/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}"
# 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/Proxy/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
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/Proxy/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 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.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: Failed to retrieve access token. Status code: {tokenResponse.StatusCode}");
string errorBody = await tokenResponse.Content.ReadAsStringAsync();
Console.WriteLine($"Response: {errorBody}");
return;
}
// Make the API request
string apiEndpoint = "{{baseurl}}/api/v1/Proxy/GetList?customerIssuerId=1";
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.IsSuccessStatusCode)
{
JsonDocument jsonResponse = JsonDocument.Parse(apiResponseBody);
string formattedJson = JsonSerializer.Serialize(jsonResponse, new JsonSerializerOptions { WriteIndented = true });
Console.WriteLine(formattedJson);
}
else
{
Console.WriteLine($"Error: API request failed. Status code: {apiResponse.StatusCode}");
Console.WriteLine($"Response: {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';
// Prepare the Token Request Data
const tokenData = new URLSearchParams({
grant_type: 'client_credentials',
client_id: clientId,
client_secret: clientSecret
}).toString();
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() {
try {
// Make a POST Request to get token
const tokenResponse = await makeRequest(tokenEndpoint, {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
}, tokenData);
// Handle the Response
if (tokenResponse.statusCode !== 200) {
console.error('Error obtaining access token:', tokenResponse.body);
return;
}
const tokenResult = JSON.parse(tokenResponse.body);
const accessToken = tokenResult.access_token;
// Make the API Request to GetList endpoint
const apiUrl = '{{baseurl}}/api/v1/Proxy/GetList?customerIssuerId=1';
const apiResponse = await makeRequest(apiUrl, {
method: 'GET',
headers: {
'Authorization': `Bearer ${accessToken}`,
'Content-Type': 'application/json'
}
});
// Print the Response
if (apiResponse.statusCode === 200) {
const jsonResponse = JSON.parse(apiResponse.body);
console.log(JSON.stringify(jsonResponse, null, 2));
} else {
console.error('API Error:', apiResponse.statusCode, apiResponse.body);
}
} 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/Proxy/GetList';
const apiResponse = await axios.get(apiEndpoint, {
headers: {
'Authorization': `Bearer ${accessToken}`,
'Content-Type': 'application/json',
},
params: {
customerIssuerId: 1,
},
});
// 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.message}`);
if (error.response) {
console.error(`Status: ${error.response.status}`);
console.error(`Response: ${JSON.stringify(error.response.data, null, 2)}`);
}
} else {
console.error('An unexpected error occurred:', error);
}
}
}
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';
// Prepare the Token Request Data
const tokenData = new URLSearchParams({
grant_type: 'client_credentials',
client_id: clientId,
client_secret: clientSecret
}).toString();
// 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() {
try {
// Make a POST request to get token
const tokenResponse = await makeRequest(tokenEndpoint, {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
}, tokenData);
// Handle the Response
if (tokenResponse.statusCode === 200) {
const tokenJson = JSON.parse(tokenResponse.body);
const accessToken = tokenJson.access_token;
// Make the API Request to GetList endpoint
const apiUrl = '{{baseurl}}/api/v1/Proxy/GetList?customerIssuerId=1';
const apiResponse = await makeRequest(apiUrl, {
method: 'GET',
headers: {
'Authorization': `Bearer ${accessToken}`,
'Content-Type': 'application/json'
}
});
// Print the Response
const responseJson = JSON.parse(apiResponse.body);
console.log(JSON.stringify(responseJson, null, 2));
} else {
console.error('Error retrieving access token:', tokenResponse.statusCode, tokenResponse.body);
}
} catch (error) {
console.error('Error:', error.message);
}
}
main();
200 Response:
[
{
"proxyId": 302100,
"issuer": "Alaska Air Group, Inc.",
"security": "Common",
"totalShares": 492350,
"totalSharesFormat": "492,350",
"totalVotedShares": 0,
"totalVotedSharesFormat": "0",
"title": "proxy 10",
"quorum": "10%",
"recordDate": "8/30/2018",
"mailingDate": "8/31/2018",
"meetingDateTime": "10/31/2018 @ 07:00 AM PST",
"voteCloseDateTime": "11/01/2018 @ 07:00 AM PST",
"status": "Closed"
},
{
"proxyId": 3029,
"issuer": "Alaska Air Group, Inc.",
"security": "Common",
"totalShares": 6463100,
"totalSharesFormat": "6,463,100",
"totalVotedShares": 1500,
"totalVotedSharesFormat": "1,500",
"title": "proxy2",
"quorum": "2%",
"recordDate": "10/28/2019",
"mailingDate": "",
"meetingDateTime": "10/31/2019 @ 07:00 AM PST",
"voteCloseDateTime": "",
"status": "Closed"
}
]
POST Proxy/GenerateProxyDetails#
Description:
Generates details for a specific proxy.
Request Body:
customerProxyId
integer
Required
Nullable
Your Customer Proxy Id.
includeNotVotedShares
boolean
Required
Non-nullable
true
= includes shares that haven't been voted on yet.
false
= does not include shares that haven't been voted on yet.
isPDF
boolean
Required
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/Proxy/GenerateProxyDetails' \
--header 'Authorization: Bearer <YOUR TOKEN>' \
--header 'Content-Type: application/json' \
--data '{"example": "data"}'
#!/bin/bash
# Set up environment variables
CLIENT_ID="${SOLO_CLIENT_ID}"
CLIENT_SECRET="${SOLO_CLIENT_SECRET}"
# 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
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
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/Proxy/GenerateProxyDetails"
# Prepare the request body
REQUEST_BODY='{
"controlProxyId": 1,
"customerProxyId": 1,
"includeNotVotedShares": false,
"isPDF": false
}'
# Make the API request
API_RESPONSE=$(curl -s -X POST "${API_ENDPOINT}" \
-H "Authorization: Bearer ${ACCESS_TOKEN}" \
-H "Content-Type: application/json" \
-d "${REQUEST_BODY}")
# Print the 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/Proxy/GenerateProxyDetails"
headers = {
"Authorization": f"Bearer {access_token}",
"Content-Type": "application/json"
}
request_body = {
"controlProxyId": 1,
"customerProxyId": 1,
"includeNotVotedShares": False,
"isPDF": False
}
api_response = requests.post(api_url, headers=headers, json=request_body)
# 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 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);
string accessToken = null;
// Handle the response
if (tokenResponse.StatusCode == System.Net.HttpStatusCode.OK)
{
string tokenResponseBody = await tokenResponse.Content.ReadAsStringAsync();
using JsonDocument tokenJson = JsonDocument.Parse(tokenResponseBody);
accessToken = tokenJson.RootElement.GetProperty("access_token").GetString();
}
else
{
Console.WriteLine($"Error: Failed to retrieve access token. Status code: {tokenResponse.StatusCode}");
string errorBody = await tokenResponse.Content.ReadAsStringAsync();
Console.WriteLine($"Response: {errorBody}");
return;
}
// Make the API request
string apiEndpoint = "{{baseurl}}/api/v1/Proxy/GenerateProxyDetails";
// Prepare the request body
var requestBody = new
{
controlProxyId = 1,
customerProxyId = 1,
includeNotVotedShares = false,
isPDF = false
};
string jsonRequestBody = JsonSerializer.Serialize(requestBody);
var content = new StringContent(jsonRequestBody, Encoding.UTF8, "application/json");
// Set the authorization header
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
// Send the POST request
HttpResponseMessage apiResponse = await httpClient.PostAsync(apiEndpoint, content);
// Print the response
string apiResponseBody = await apiResponse.Content.ReadAsStringAsync();
if (apiResponse.StatusCode == System.Net.HttpStatusCode.OK)
{
try
{
using JsonDocument jsonDoc = JsonDocument.Parse(apiResponseBody);
string formattedJson = JsonSerializer.Serialize(jsonDoc.RootElement, new JsonSerializerOptions { WriteIndented = true });
Console.WriteLine(formattedJson);
}
catch (JsonException)
{
Console.WriteLine(apiResponseBody);
}
}
else
{
Console.WriteLine($"Error: API request failed. Status code: {apiResponse.StatusCode}");
Console.WriteLine($"Response: {apiResponseBody}");
}
}
}
const https = require('https');
const http = require('http');
// 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';
// Prepare the Token Request Data
const tokenData = new URLSearchParams({
grant_type: 'client_credentials',
client_id: clientId,
client_secret: clientSecret
}).toString();
// Function to make HTTP requests
function makeRequest(url, options, data = null) {
return new Promise((resolve, reject) => {
const urlObj = new URL(url);
const protocol = urlObj.protocol === 'https:' ? https : http;
const req = protocol.request(url, options, (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();
});
}
async function main() {
try {
// Make a POST request to get token
const tokenResponse = await makeRequest(tokenEndpoint, {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
}, tokenData);
// Handle the Response
if (tokenResponse.statusCode === 200) {
const tokenResult = JSON.parse(tokenResponse.body);
const accessToken = tokenResult.access_token;
// Make the API Request to GenerateProxyDetails endpoint
const apiUrl = '{{baseurl}}/api/v1/Proxy/GenerateProxyDetails';
// Request body from the curl example
const requestBody = JSON.stringify({
controlProxyId: 1,
customerProxyId: 1,
includeNotVotedShares: false,
isPDF: false
});
const apiResponse = await makeRequest(apiUrl, {
method: 'POST',
headers: {
'Authorization': `Bearer ${accessToken}`,
'Content-Type': 'application/json'
}
}, requestBody);
// Print the Response
if (apiResponse.body) {
const jsonResponse = JSON.parse(apiResponse.body);
console.log(JSON.stringify(jsonResponse, null, 2));
} else {
console.log('Response status:', apiResponse.statusCode);
}
} else {
console.error('Error getting token:', tokenResponse.statusCode, tokenResponse.body);
}
} catch (error) {
console.error('Error:', error.message);
}
}
main();
import axios from 'axios';
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);
}
const tokenEndpoint = '{{baseurl}}/connect/token';
const apiBaseUrl = '{{baseurl}}';
async function getAccessToken(): Promise<string | null> {
const tokenRequestData = new URLSearchParams({
grant_type: 'client_credentials',
client_id: clientId!,
client_secret: clientSecret!,
});
try {
const response = await axios.post(tokenEndpoint, tokenRequestData.toString(), {
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
});
if (response.status === 200) {
return response.data.access_token;
} else {
console.error('Error: Failed to retrieve access token. Status:', response.status);
return null;
}
} catch (error) {
console.error('Error: Failed to retrieve access token.', error);
return null;
}
}
async function generateProxyDetails(accessToken: string): Promise<void> {
const endpoint = `${apiBaseUrl}/api/v1/Proxy/GenerateProxyDetails`;
const requestBody = {
controlProxyId: 1,
customerProxyId: 1,
includeNotVotedShares: false,
isPDF: false,
};
try {
const response = await axios.post(endpoint, requestBody, {
headers: {
Authorization: `Bearer ${accessToken}`,
'Content-Type': 'application/json',
},
});
console.log('Response:', JSON.stringify(response.data, null, 2));
} catch (error) {
if (axios.isAxiosError(error)) {
console.error('Error: API request failed. Status:', error.response?.status);
console.error('Response:', error.response?.data);
} else {
console.error('Error: API request failed.', error);
}
}
}
async function main(): Promise<void> {
const accessToken = await getAccessToken();
if (!accessToken) {
console.error('Error: Unable to proceed without access token');
process.exit(1);
}
await generateProxyDetails(accessToken);
}
main();
const https = require('https');
const http = require('http');
const url = require('url');
// Set up 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';
// Prepare the Token Request Data
const tokenData = new URLSearchParams({
grant_type: 'client_credentials',
client_id: clientId,
client_secret: clientSecret
}).toString();
// Function to make HTTP requests
function makeRequest(requestUrl, options, postData = null) {
return new Promise((resolve, reject) => {
const parsedUrl = url.parse(requestUrl);
const protocol = parsedUrl.protocol === 'https:' ? https : http;
const reqOptions = {
hostname: parsedUrl.hostname,
port: parsedUrl.port,
path: parsedUrl.path,
...options
};
const req = protocol.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();
});
}
async function main() {
try {
// Make a POST request to get token
const tokenResponse = await makeRequest(tokenEndpoint, {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
}, tokenData);
// Handle the Response
if (tokenResponse.statusCode === 200) {
const tokenJson = JSON.parse(tokenResponse.body);
const accessToken = tokenJson.access_token;
// Make the API Request
const apiEndpoint = '{{baseurl}}/api/v1/Proxy/GenerateProxyDetails';
const requestBody = JSON.stringify({
controlProxyId: 1,
customerProxyId: 1,
includeNotVotedShares: false,
isPDF: false
});
const apiResponse = await makeRequest(apiEndpoint, {
method: 'POST',
headers: {
'Authorization': `Bearer ${accessToken}`,
'Content-Type': 'application/json'
}
}, requestBody);
// Print the Response
const responseJson = JSON.parse(apiResponse.body);
console.log(JSON.stringify(responseJson, null, 2));
} else {
console.error('Error getting token:', tokenResponse.statusCode, tokenResponse.body);
}
} catch (error) {
console.error('Error:', error.message);
}
}
main();
200 Response:
{
"downloadUrl": "{{baseurl}}/Api/v1/Report/DownloadReport/CfDJ8G2a_F-j-rtGiUBjbT5isV09BVpVehT24o8YZJjnpIaz-FE8LPFSN4SVvcZxgrpQJaV5E9vCsWrGcytlXYNEV_hJawiszPIEoVJdX0M7Nn69PZOTO6A4ulz7fCnk8wQ5nQuR_gFIR2St2FSOVG3LuZAmUEcstEMuzNbAd9cBEJea/proxy-3029.pdf/CfDJ8G2a_F-j-rtGiUBjbT5isV0GdswlqrZFUtmb0EoHcEuQ2yBeKQnfHvvI12VVFtjOZKA9J_bHW26zD84_eZ3Y84dUNfVfi69veuQ1SPXWEuofzRKX_6pE8_V0qhc02hFs0NAGJWbQR-5URn1jsAzZqCc"
}