montesuma80 / 3cx-web-api Goto Github PK
View Code? Open in Web Editor NEWan local API to Controll your 3CX v16/v18 over HTTP
an local API to Controll your 3CX v16/v18 over HTTP
Hi my friend,
Is there anyway to merge 2 seperate active calls? For example call1 is in a CFD script and listening a wav file and other call same as call1. Trying to merge this two calls and backoff. Like conferencing.
Hi,
I can't seem to be able to get the WebAPICore.csproj to build successfully. It gives me the following output:
CSC : error CS1705: Assembly '3cxpscomcpp2' with identity '3cxpscomcpp2, Version=4.0.0.0, Culture=neutral, PublicKeyToken=53c4927ce4749cb4' uses 'System.Runtime, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' which has a higher version than referenced assembly 'System.Runtime' with identity 'System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' [/3cx-web-API/WebAPICore.csproj]
16 Warning(s)
1 Error(s)
It is running on Debian 12 and has .net5.0 installed. I have updated the csproj file to reference the 3cxpscomcpp2.dll file accordingly. I am not sure on what I need to do for this: "3CXPhoneSystem.ini (Debian User must fix the Path in the ini for the 3cxpscomcpp2.dll)".
Please could you provide some pointers as to where I appear to be going wrong?
Thanks
Arif
With the lastest v18u8 the .net version changed to .Net 6.
I needed to add a return value in the update.cs for the catch case. After that it compiled and worked with the latest 3cx version.
Build on 3cx Debian 10.
MSBuild version 17.3.2+561848881 for .NET
Determining projects to restore...
Restored /opt/3cx-web-api/WebAPICore.csproj (in 203 ms).
/opt/3cx-web-api/update.cs(16,30): error CS0161: 'update.updateid(string, string)': not all code paths return a value [/opt/3cx-web-api/WebAPICore.csproj]
/opt/3cx-web-api/getcallid.cs(29,38): warning CS0618: 'ActiveConnection.HistoryIDOfTheCall' is obsolete: 'V14. This ID is not stored in call history database. So this property should not be used to store references' [/opt/3cx-web-api/WebAPICore.csproj]
Build FAILED.
/opt/3cx-web-api/getcallid.cs(29,38): warning CS0618: 'ActiveConnection.HistoryIDOfTheCall' is obsolete: 'V14. This ID is not stored in call history database. So this property should not be used to store references' [/opt/3cx-web-api/WebAPICore.csproj]
/opt/3cx-web-api/update.cs(16,30): error CS0161: 'update.updateid(string, string)': not all code paths return a value [/opt/3cx-web-api/WebAPICore.csproj]
1 Warning(s)
1 Error(s)
Time Elapsed 00:00:03.18
Hi,
I'm trying to setup the 3cx Web API on my local machine but I couldn't get past the error message "Unable to load DLL 'tcxpscom_native' or one of its dependencies" when running the command 'dotnet WebAPICore.dll'.
Here's the full error message am getting:
System.DllNotFoundException: Unable to load DLL 'tcxpscom_native' or one of its dependencies: The specified module could not be found. (0x8007007E)
at TCX.Configuration.PhoneSystem.RegisterListener(MyPFN_UPDATE_LISTENER f)
at TCX.Configuration.PhoneSystem..ctor()
at TCX.Configuration.PhoneSystem.Reset(String ApplicationName, String CfgServerHost, Int32 CfgServerPort, String CfgServerUser, String CfgServerPassword, NotificationEventHandler inserted, NotificationEventHandler updated, NotificationEventHandler deleted)
at WebAPI.Program.Bootstrap(String[] args) in C:....\3cx-web-API\Program.cs:line 58
at WebAPI.Program.Main(String[] args) in C:....\3cx-web-API\Program.cs:line 426
Could you please provide me some pointers on how to resolve this error.
Thank you in advance and your help will be very much appreciated.
-Dan
Hello,
When Stopping the API a error i shown:
`
/stop
hi,
we freshly build on newest version and every request is returned with null.
Just asking if some can confirm it works with latest 3cx build
thanks
c280
Dear Ladies and Gentlemen,
I am getting an error while compiling.
CSC : error CS1705: Assembly '3cxpscomcpp2' with identity '3cxpscomcpp2, Version=2.0.0.0, Culture=neutral, PublicKeyToken=53c4927ce4749cb4' uses 'System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' which has a higher version than referenced assembly 'System.Runtime' with identity 'System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' [/root/3cx-web-API/WebAPICore.csproj]
To be honest I have searched a lot and have no clue how to solve it.
Could someone help?
Regards
How easy is it to use this to implement a webhook on an incoming call? I need to monitor a queue for calls and process background jobs for particular numbers.
API set up and running on 8888 on test system and trying something like showallcalls
I can see it picked up the calls in the debug window, but after them
"Object reference not set to an instance of an object."
Browser or curl requests just seem to hang.
3CX Version: 18.0 (Build 312)
3CXPhoneSystem.ini: /usr/share/3cxpbx/skel/Bin/3CXPhoneSystem.ini
When I run the api and try to call it I get the following response: ConfigServer is not connected
Request: curl http://localhost:8888/showstatus/10/
Response:
/showstatus/10/
ConfigServer is not connected
Hi,
My environment is as follows:
The PBX is a fresh install with all updates and the code is from the MASTER branch. I have updated the location of 3cxpscomcpp2.dll and removed the private/false line in WebAPICore.csproj. Below is the compile error:
voipl@3cx:~/3cx-web-API-Master$ dotnet build WebAPICore.csproj
Microsoft (R) Build Engine version 16.11.2+f32259642 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.
Determining projects to restore...
All projects are up-to-date for restore.
/home/voipl/3cx-web-API-Master/update.cs(16,30): error CS0161: 'update.updateid(string, string)': not all code paths return a value [/home/voipl/3cx-web-API-Master/WebAPICore.csproj]
/home/voipl/3cx-web-API-Master/getcallid.cs(29,38): warning CS0618: 'ActiveConnection.HistoryIDOfTheCall' is obsolete: 'V14. This ID is not stored in call history database. So this property should not be used to store references' [/home/voipl/3cx-web-API-Master/WebAPICore.csproj]
Build FAILED.
/home/voipl/3cx-web-API-Master/getcallid.cs(29,38): warning CS0618: 'ActiveConnection.HistoryIDOfTheCall' is obsolete: 'V14. This ID is not stored in call history database. So this property should not be used to store references' [/home/voipl/3cx-web-API-Master/WebAPICore.csproj]
/home/voipl/3cx-web-API-Master/update.cs(16,30): error CS0161: 'update.updateid(string, string)': not all code paths return a value [/home/voipl/3cx-web-API-Master/WebAPICore.csproj]
1 Warning(s)
1 Error(s)
Time Elapsed 00:00:02.97
I'm not able to work out why the compile is failing as it looks like a generic issue but I can't see the cause.
Thanks.
Hello. We are 3CX partner and testing your API.
Will you describe some moments?
I get the following error when running the application:
root@srv-pabx-02:~/3cx-web-API-master/bin/Debug/netcoreapp3.1# dotnet WebAPICore.dll 8888
System.IO.FileNotFoundException: Could not load file or assembly '3cxpscomcpp2, Version=2.0.0.0, Culture=neutral, PublicKeyToken=XXXXX'. The system cannot find the file specified.
File name: '3cxpscomcpp2, Version=2.0.0.0, Culture=neutral, PublicKeyToken=####'
at WebAPI.Program.Bootstrap(String[] args)
at WebAPI.Program.Main(String[] args) in /root/3cx-web-API-master/Program.cs:line 418
hi ,
in 3cx v20 in Conferencing we can generate api key " Allows remote creation, deletion and update via REST API calls "
how can limit this api to this api key ?
i want use key for request and if i change api key from 3cx , api work with new key
sorry for my bad English
Hi,
as I'm not good in serving HTTP/S Applications under windows my question is: what is the best way to publish the API?
I thought about following methods:
The advantage of a reverse proxy would be Authorzation and SSL termination.
How you guys did it?
Hello. I managed to compile and run the API successfully but had to use .NET 8.0 to do so.
CSC : error CS1705: Assembly '3cxpscomcpp2' with identity '3cxpscomcpp2, Version=4.0.0.0, Culture=neutral, PublicKeyToken=53c4927ce4749cb4' uses 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' which has a higher version than referenced assembly 'System.Runtime' with identity 'System.Runtime, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' [/root/downloads/3cx-web-API/WebAPICore.csproj]
Now when i attempt to do anything via the API i only ever get this response: Idle
Is the latest version no longer compatible with this web API or is there a way for me to get it running on V20 update 1? Perhaps i made a mistake but i did have it working on V18 in the past. Any guidance would be appreciated.
Hi,
I followed the instructions for Debian.
When trying to compile I am getting this error:
SC : error CS1705: Assembly "3cxpscomcpp2" mit Identität "3cxpscomcpp2, Version=2.0.0.0, Culture=neutral, PublicKeyToken=53c4927ce4749cb4" verwendet "System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" mit einer höheren Version als die referenzierte Assembly "System.Runtime" mit Identität "System.Runtime, Version=4.2.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a". [/home/mkletzin/3cx-web-API/WebAPICore.csproj]
Anybody an idea?
Thanks
Michael
Thank you for this awesome piece of software!
I am updating the presence state in O365 using your API (I am not even using the HTTP part though, but StdOut instead).
This is extremely awkward as I constantly have to poll the /showallcalls endpoint.
#!/bin/bash
declare -A users
declare -A statechange
# extension to O365 user ID mapping
users["100"]='[email protected]'
users["101"]='[email protected]'
# status refresh time in seconds
refresh=10
# regex to match state and extension
busy_match="^\s*ID=.*;S=(Dialing|Connected);DN=(.*);Queue_Name="
# initialize some state data
for i in "${!users[@]}" ; do
statechange[$i]=0
done
# loop over StdOutput of the call processing API
while read line
do
now=$(date +%s)
# exit if the API server received a /stop command
if [[ "$line" =~ "Server Stop" ]] ; then
exit 0
# check if a call is being set up or already connected
elif [[ "$line" =~ $busy_match ]] ; then
ext=${BASH_REMATCH[2]}
# process further if the extension is in the user mapping
if [ -n "${users[$ext]}" ] ; then
# has there been a state change during the last refresh period?
if [ $((now - statechange[$ext])) -gt $((15 * refresh / 10)) ] ; then
./teams_presence.sh "${users[$ext]}" busy
fi
statechange[$ext]=$now
fi
elif [[ "$line" =~ (<html>|Listening) ]] ; then
# set any users to "available" who are still busy but not in the active call list
for i in "${!statechange[@]}" ; do
# extension is not currently in a call, but the time it was is less than 1.5 * refresh period
if [ ${statechange["$i"]} -ne $now -a $((now - statechange[$i])) -lt $((15 * refresh / 10)) ] ; then
./teams_presence.sh "${users[$i]}" available
fi
done
sleep $refresh
# trigger the call processing API
wget -q -O - http://localhost:8888/showallcalls > /dev/null
fi
done < <(dotnet WebAPICore.dll 8888 debug)
It got me thinking, if it would be possible to add a websocket handler to the existing code. That way a client could register for state updates concerning a certain extension. I have zero knowledge about the threading model of your server, but for starters one additional websocket connection would do 😄
Much less do I currently understand the call processing API and if it includes any event driven options.
If you had any similar thoughts, let's exchange!
Hi,
I've created a script to generate WAV with the help of the Google Cloud. But If i overwrite an existing wav file, it's only been used when I commit it with the webinterface or by restarting the 3CX services.
If you can add some functions of the IVR in your api...
3CX Version: V18 Update1 Windows Version
I just can access the API in 3CX Server, but I can't access with other IPs.
I checked the firewall settings and no API ports are blocked
Hi,
Is there any possibility for merging 2 active calls? I have got one active call at CFD when other call is connected to pbx i will merge them. Any idea?
Hi Montesuma80, I tried to compile using dot net 8.0 but gave me this error:
/root/3cx-web-API/update.cs(16,30): error CS0161: 'update.updateid(string, string)': not all code paths return a value [/root/3cx-web-API/WebAPICore.csproj] Notices: 16 Errors: 1
I have correct into WebAPICore.csproj the version to "net8.0" and the other two params like describe in README.
Need to do something else?
The 3CX version is V20, specifically 20.0 Update 1 (Build 731 Release).
Kind regards
Hi,
Answer call not working for Mobile Phone or Webrtc. Its working only for Windows Softphone and physical phones.
I'm trying to setup a missed call alert webhook in the makecall.cs file.
I'm trying with this code. but it is not working, can you please suggest me the right approach for this?
private static void OnCallStateChanged(object sender, TCX.PBXAPI.CallStateChangedEventArgs e)
{
if (e.State == CallState.Missed || e.State == CallState.NotAnswered)
{
NotifyMissedCall(token: authToken, args1: e.FromExtension, args2: e.ToExtension, args3: e.CallDuration.ToString()); // Call your API to notify about the missed call
}
}
private static void NotifyMissedCall(string token, string args1, string args2, string args3)
{
string apiUrl = "https://your-api-url/missed-call-notification";
string postData = $"{{\"token\": \"{token}\", \"fromExtension\": \"{args1}\", \"toExtension\": \"{args2}\", \"callDuration\": \"{args3}\"}}";
using (var client = new WebClient())
{
client.Headers[HttpRequestHeader.ContentType] = "application/json";
string response = client.UploadString(apiUrl, "POST", postData);
Console.WriteLine("API Response: " + response);
}
}
First of all, Thank you for that great tool.
Everything was working fine but out of nowehre the Return Value of the getstatus request changes to "idle". Everything else is working nice. I tried to delete everthing but that didnt solve anything.
Is it possible to use this API from Angular app for calling and receiving calls?
I am trying to follow steps as mention below , I have installed dot net core 3.1 when I run "dotnet build WebAPICore.csproj" it give me below error.
_Microsoft (R) Build Engine version 16.7.2+b60ddb6f4 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.
Determining projects to restore...
All projects are up-to-date for restore.
C:\Program Files\dotnet\sdk\3.1.415\Microsoft.Common.CurrentVersion.targets(2084,5): warning MSB3277: Found conflicts between different versions of "System.Collections.Concurrent" that could not be resolved. These reference conflicts are listed in the build log when log verbosity is set to detailed. [C:\inetpub\wwwroot\api\WebAPICore.csproj]
C:\Program Files\dotnet\sdk\3.1.415\Microsoft.Common.CurrentVersion.targets(2084,5): warning MSB3277: Found conflicts between different versions of "System.Collections" that could not be resolved. These reference conflicts are listed in the build log when log verbosity is set to detailed. [C:\inetpub\wwwroot\api\WebAPICore.csproj]
C:\Program Files\dotnet\sdk\3.1.415\Microsoft.Common.CurrentVersion.targets(2084,5): warning MSB3277: Found conflicts between different versions of "System.Linq" that could not be resolved. These reference conflicts are listed in the build log when log verbosity is set to detailed. [C:\inetpub\wwwroot\api\WebAPICore.csproj]
C:\Program Files\dotnet\sdk\3.1.415\Microsoft.Common.CurrentVersion.targets(2084,5): warning MSB3277: Found conflicts between different versions of "System.Runtime.InteropServices" that could not be resolved. These reference conflicts are listed in the build log when log verbosity is set to detailed. [C:\inetpub\wwwroot\api\WebAPICore.csproj]
C:\Program Files\dotnet\sdk\3.1.415\Microsoft.Common.CurrentVersion.targets(2084,5): warning MSB3277: Found conflicts between different versions of "System.Runtime" that could not be resolved. These reference conflicts are listed in the build log when log verbosity is set to detailed. [C:\inetpub\wwwroot\api\WebAPICore.csproj]
C:\Program Files\dotnet\sdk\3.1.415\Microsoft.Common.CurrentVersion.targets(2084,5): warning MSB3277: Found conflicts between different versions of "System.Security.Cryptography.Algorithms" that could not be resolved. These reference conflicts are listed in the build log when log verbosity is set to detailed. [C:\inetpub\wwwroot\api\WebAPICore.csproj]
C:\Program Files\dotnet\sdk\3.1.415\Microsoft.Common.CurrentVersion.targets(2084,5): warning MSB3277: Found conflicts between different versions of "System.Threading" that could not be resolved. These reference conflicts are listed in the build log when log verbosity is set to detailed. [C:\inetpub\wwwroot\api\WebAPICore.csproj]
C:\Program Files\dotnet\sdk\3.1.415\Microsoft.Common.CurrentVersion.targets(2084,5): warning MSB3277: Found conflicts between different versions of "System.Xml.ReaderWriter" that could not be resolved. These reference conflicts are listed in the build log when log verbosity is set to detailed. [C:\inetpub\wwwroot\api\WebAPICore.csproj]
C:\Program Files\dotnet\sdk\3.1.415\Microsoft.Common.CurrentVersion.targets(2084,5): warning MSB3277: Found conflicts between different versions of "System.Xml.XDocument" that could not be resolved. These reference conflicts are listed in the build log when log verbosity is set to detailed. [C:\inetpub\wwwroot\api\WebAPICore.csproj]
C:\Program Files\dotnet\sdk\3.1.415\Microsoft.Common.CurrentVersion.targets(2084,5): warning MSB3277: Found conflicts between different versions of "System.Xml.XmlSerializer" that could not be resolved. These reference conflicts are listed in the build log when log verbosity is set to detailed. [C:\inetpub\wwwroot\api\WebAPICore.csproj]
CSC : error CS1705: Assembly '3cxpscomcpp2' with identity '3cxpscomcpp2, Version=2.0.0.0, Culture=neutral, PublicKeyToken=53c4927ce4749cb4' uses 'System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' which has a higher version than referenced assembly 'System.Runtime' with identity 'System.Runtime, Version=4.2.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' [C:\inetpub\wwwroot\api\WebAPICore.csproj]
Build FAILED.
C:\Program Files\dotnet\sdk\3.1.415\Microsoft.Common.CurrentVersion.targets(2084,5): warning MSB3277: Found conflicts between different versions of "System.Collections.Concurrent" that could not be resolved. These reference conflicts are listed in the build log when log verbosity is set to detailed. [C:\inetpub\wwwroot\api\WebAPICore.csproj]
C:\Program Files\dotnet\sdk\3.1.415\Microsoft.Common.CurrentVersion.targets(2084,5): warning MSB3277: Found conflicts between different versions of "System.Collections" that could not be resolved. These reference conflicts are listed in the build log when log verbosity is set to detailed. [C:\inetpub\wwwroot\api\WebAPICore.csproj]
C:\Program Files\dotnet\sdk\3.1.415\Microsoft.Common.CurrentVersion.targets(2084,5): warning MSB3277: Found conflicts between different versions of "System.Linq" that could not be resolved. These reference conflicts are listed in the build log when log verbosity is set to detailed. [C:\inetpub\wwwroot\api\WebAPICore.csproj]
C:\Program Files\dotnet\sdk\3.1.415\Microsoft.Common.CurrentVersion.targets(2084,5): warning MSB3277: Found conflicts between different versions of "System.Runtime.InteropServices" that could not be resolved. These reference conflicts are listed in the build log when log verbosity is set to detailed. [C:\inetpub\wwwroot\api\WebAPICore.csproj]
C:\Program Files\dotnet\sdk\3.1.415\Microsoft.Common.CurrentVersion.targets(2084,5): warning MSB3277: Found conflicts between different versions of "System.Runtime" that could not be resolved. These reference conflicts are listed in the build log when log verbosity is set to detailed. [C:\inetpub\wwwroot\api\WebAPICore.csproj]
C:\Program Files\dotnet\sdk\3.1.415\Microsoft.Common.CurrentVersion.targets(2084,5): warning MSB3277: Found conflicts between different versions of "System.Security.Cryptography.Algorithms" that could not be resolved. These reference conflicts are listed in the build log when log verbosity is set to detailed. [C:\inetpub\wwwroot\api\WebAPICore.csproj]
C:\Program Files\dotnet\sdk\3.1.415\Microsoft.Common.CurrentVersion.targets(2084,5): warning MSB3277: Found conflicts between different versions of "System.Threading" that could not be resolved. These reference conflicts are listed in the build log when log verbosity is set to detailed. [C:\inetpub\wwwroot\api\WebAPICore.csproj]
C:\Program Files\dotnet\sdk\3.1.415\Microsoft.Common.CurrentVersion.targets(2084,5): warning MSB3277: Found conflicts between different versions of "System.Xml.ReaderWriter" that could not be resolved. These reference conflicts are listed in the build log when log verbosity is set to detailed. [C:\inetpub\wwwroot\api\WebAPICore.csproj]
C:\Program Files\dotnet\sdk\3.1.415\Microsoft.Common.CurrentVersion.targets(2084,5): warning MSB3277: Found conflicts between different versions of "System.Xml.XDocument" that could not be resolved. These reference conflicts are listed in the build log when log verbosity is set to detailed. [C:\inetpub\wwwroot\api\WebAPICore.csproj]
C:\Program Files\dotnet\sdk\3.1.415\Microsoft.Common.CurrentVersion.targets(2084,5): warning MSB3277: Found conflicts between different versions of "System.Xml.XmlSerializer" that could not be resolved. These reference conflicts are listed in the build log when log verbosity is set to detailed. [C:\inetpub\wwwroot\api\WebAPICore.csproj]
CSC : error CS1705: Assembly '3cxpscomcpp2' with identity '3cxpscomcpp2, Version=2.0.0.0, Culture=neutral, PublicKeyToken=53c4927ce4749cb4' uses 'System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' which has a higher version than referenced assembly 'System.Runtime' with identity 'System.Runtime, Version=4.2.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' [C:\inetpub\wwwroot\api\WebAPICore.csproj]
10 Warning(s)
1 Error(s)
Time Elapsed 00:00:01.81_
Any idea ..
I am using 3cx v18 , OS window.
Hello Team,
When use "MakeCall" Api For Call. And Get Call Id. Like "CallID: 00000C2612B8D579_36". Now Any Way there for checking Call status using Given Call ID ?
This is Great & works like a charm!!
Kudos to the authors of this API
Is this API scalable and safe to use for production systems having concurrent call licenses above 64 or 96?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.