- Joined
- Jul 30, 2018
- Messages
- 9
- Reaction score
- 1
Hi,
I'm using 3CX V16 and trying to use API to retrieve all the information from the server, but API doesn't return anything.
Here is a result
Please help me to solve this. I don't why result is an empty
I'm using 3CX V16 and trying to use API to retrieve all the information from the server, but API doesn't return anything.
C#:
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using TCX.Configuration;
namespace _3cxApiTest
{
class Program
{
public static bool Stop { get; private set; }
static void Main(string[] args)
{
DisplayAllInfo();
Console.ReadLine();
}
static void DisplayAllInfo()
{
bool configSrvConn = false;
int checkCount = 0;
var a = new Random(Environment.TickCount);
PhoneSystem.ApplicationName = "TestApi" + a.Next().ToString();
var ps = PhoneSystem.Reset(
PhoneSystem.ApplicationName + new Random(Environment.TickCount).Next().ToString(),
"127.0.0.1", 5485, "cfguser_default", "7f33hcpyurap");
Console.WriteLine(PhoneSystem.ApplicationName);
do
{
try
{
configSrvConn = PhoneSystem.Root.Connected;
}
catch (Exception exc)
{
Console.WriteLine("Configuration server not connected. Waiting 10 seconds to retry: " + exc.Message);
Thread.Sleep(10000);
checkCount++;
}
} while (!configSrvConn && checkCount < 6);
Console.WriteLine("Connected to PBX: " + configSrvConn.ToString());
Console.BackgroundColor = ConsoleColor.DarkBlue;
try
{
Console.WriteLine("Parameters:");
foreach (Parameter p in ps.GetParameters())
{
Console.WriteLine("\t" + p.ToString());
}
Console.WriteLine("Codecs:");
foreach (Codec c in ps.GetCodecs())
{
Console.WriteLine("\t" + c.ToString());
}
Console.WriteLine("Conditions:");
foreach (RuleCondition rc in ps.GetRuleConditions())
{
Console.WriteLine("\t" + rc.ToString());
}
Console.WriteLine("RuleHours:");
foreach (RuleHours rh in ps.GetRuleHourTypes())
{
Console.WriteLine("\t" + rh.ToString());
}
Console.WriteLine("RuleCalltype:");
foreach (RuleCallType rct in ps.GetRuleCallTypes())
{
Console.WriteLine("\t" + rct.ToString());
}
}
catch (Exception e)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.Write("ERROR: ");
Console.ForegroundColor = ConsoleColor.White;
Console.Write(e.ToString());
}
Console.Write("Press enter to Continue!");
Console.ReadLine();
}
}
}
Here is a result
Code:
TestApi9002804421087552196
Connected to PBX: True
Parameters:
Codecs:
Conditions:
RuleHours:
RuleCalltype:
Press enter to Continue!
Please help me to solve this. I don't why result is an empty