logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
jhghar  
#1 Posted : Wednesday, June 28, 2017 7:57:47 PM(UTC)
jhghar


Rank: Guest

Joined: 6/28/2017(UTC)
Posts: 4
United States

Thanks: 1 times
Hello - completely new user here!

We've installed the extension template "My New Extension (from Integration Sample)" with initial hopes to retrieve the session ID (and future hopes to retrieve the URL to immediately jump into Access.

All of our curl requests produce the exact same response:

Code:

{
    "errorType": "TargetParameterCountException",
    "message": "Number of parameter does not match expected count.",
    "detail": null
}


Any initial pointers? Thanks in advance.

Edited by user Wednesday, June 28, 2017 7:59:42 PM(UTC)  | Reason: Not specified

shawnkhall  
#2 Posted : Wednesday, June 28, 2017 10:24:12 PM(UTC)
shawnkhall


Rank: Advanced Member

Medals: Level 1: Random Act of Kindness! Received One Thanks!

Joined: 2/6/2014(UTC)
Posts: 168
Man
United States

Thanks: 5 times
Was thanked: 8 time(s) in 6 post(s)
code sample? at least the function header and URL after the root (/)

i wrote up a similar extension last month in order to update a customproperty via curl and it works as expected. the biggest issue was understanding the context of how they were being called.
jhghar  
#3 Posted : Wednesday, June 28, 2017 11:43:10 PM(UTC)
jhghar


Rank: Guest

Joined: 6/28/2017(UTC)
Posts: 4
United States

Thanks: 1 times
Yes, thanks!

We're simply following the guidance in the comments of the sample integration extension:

Code:

/*
 * Calling http://support.example.com:8040/App_Extensions/5d92d2d4-e6cc-4804-90bd-5a4a64369810/Service.ashx/FindOrCreateSession/name/host
 * (replacing 5d92d2d4-e6cc-4804-90bd-5a4a64369810 with the id of your extension)
 * will return the ID of the session with the given name, creating it if it doesn't already exist.
 *
 * UpdateSession's array parameter means it can't be called with a GET request, but POST will work. For example:
 *     curl 'http://support.example.com:8040/App_Extensions/5d92d2d4-e6cc-4804-90bd-5a4a64369810/Service.ashx/UpdateSession'
 *     -d '["updater", '"$(curl 'http://support.example.com:8040/App_Extensions/5d92d2d4-e6cc-4804-90bd-5a4a64369810/Service.ashx/FindOrCreateSession/name/updater' -u Administrator)"
 *     ', "NewName", true, null, ["Custom1", "blah blah blah", "Some more stuff"]]' -u Administrator
 *
 * Both can also be easily called in Javascript from mysite.com or an allowed origin:
 *     <script src="http://support.example.com:8040/Script.ashx"></script>
 *     ...
 *     SC.service.FindOrCreateSession("name", "host", function(sessionID) {
 *         SC.service.UpdateSession("updater", sessionID, "NewName", true, null, ["Custom1", "blah blah blah", "Some more stuff"]);
 *     });
 */


Which... if we're reading correctly, has us failing with the following simple command:

Code:

curl 'http://ourserver:port/App_Extensions/XXXXX-THE-ID-WE-FOUND-IN-THE-UPPER-RIGHT-CORNER-OF-EXTENSION-XXXXX/Service.ashx/FindOrCreateSession/name/SAMPLEPC' -u Administrator


Thanks!
shawnkhall  
#4 Posted : Thursday, June 29, 2017 5:32:46 AM(UTC)
shawnkhall


Rank: Advanced Member

Medals: Level 1: Random Act of Kindness! Received One Thanks!

Joined: 2/6/2014(UTC)
Posts: 168
Man
United States

Thanks: 5 times
Was thanked: 8 time(s) in 6 post(s)
Are you posting the password for your Administrator account from curl? If not, that's probably your problem.
jhghar  
#5 Posted : Thursday, June 29, 2017 12:58:47 PM(UTC)
jhghar


Rank: Guest

Joined: 6/28/2017(UTC)
Posts: 4
United States

Thanks: 1 times
We're sending the password along. The sad part is that it doesn't seem to matter if we provide a real user name or not; it returns the original error no matter what we send. Which really makes me think we're doing something fundamentally wrong. Thanks=
Ben B  
#6 Posted : Thursday, June 29, 2017 1:13:29 PM(UTC)
Ben B


Rank: Administration

Medals: Level 2: Lent a Helping Hand! 10 Thanks!

Joined: 10/2/2015(UTC)
Posts: 227

Thanks: 1 times
Was thanked: 48 time(s) in 44 post(s)
The Integration sample you're using is a little out of date. We recommend making POST requests with content type application/json against extensions methods.

In your Integration sample, you could update the Service.ashx code to look something like this:
Code:

<%@ WebHandler Language="C#" Class="Service" %>

using System;
using System.Linq;
using System.Text.RegularExpressions;
using ScreenConnect;

[DemandPermission(PermissionInfo.AdministerPermission)]
public class Service : WebServiceBase
{	
	public Guid TryGetAccessSessionIdByName(string name)
	{
		var session = SessionManagerPool.Demux.GetSessions().FirstOrDefault(s => s.Name == name);
			
		return session.SafeNav(s => s.SessionID);
	}
}



Let's assume your sample extension's id is aaa0f6e6-59ae-4911-b9c5-455afba7d705, then your curl would look something like this if you're looking for the session id of an access session with name vubuntu14:
Code:

curl -H "Content-Type: application/json" -X POST -d "[\"vubuntu14\"]" http://localhost:8040/App_Extensions/aaa0f6e6-59ae-4911-b9c5-455afba7d705/Service.ashx/TryGetAccessSessionIdByName -u <admin user name>

and the response would look something like this:
Code:

"46f36b50-bff4-d98e-63a4-24164e64ebe3"


ScreenConnect Team
thanks 1 user thanked Ben B for this useful post.
jhghar on 6/30/2017(UTC)
jhghar  
#7 Posted : Thursday, June 29, 2017 1:42:38 PM(UTC)
jhghar


Rank: Guest

Joined: 6/28/2017(UTC)
Posts: 4
United States

Thanks: 1 times
THANKS! That worked!

So without those other functions in the Integration sample how do we go about building the other minimum requisite components of the relay://url to launch the session?

And/or... what are the other minimum components of the relay://url? In chrome dev tools we're seeing ~13 different parameters, but we're assuming that we may only need a few more to allow the session to launch.

Thanks a ton for any tips!
Conrad L  
#8 Posted : Wednesday, July 19, 2017 1:54:28 PM(UTC)
Conrad L


Rank: Administration

Joined: 7/17/2017(UTC)
Posts: 11

Thanks: 2 times
Was thanked: 6 time(s) in 5 post(s)
Originally Posted by: jhghar Go to Quoted Post
THANKS! That worked!

So without those other functions in the Integration sample how do we go about building the other minimum requisite components of the relay://url to launch the session?

And/or... what are the other minimum components of the relay://url? In chrome dev tools we're seeing ~13 different parameters, but we're assuming that we may only need a few more to allow the session to launch.

Thanks a ton for any tips!


Hi jhghar,

The components necessary for a url that can launch a session are as follows:

For a Host Session (version 6+)
http://host:port/Host#Support/the session group name//the session id/Join

For a Guest Session
http://host:port/?Session=the session id

Below are some example functions you can review that will generate these urls (note that neither of these methods do any kind of authentication):

Code:

public object CreateGuestSupportSessionLink(string sessionName, string hostName = null)
{
    //get a specific session
    var session = SessionManagerPool.Demux.GetSessions().FirstOrDefault(s => s.Name == sessionName);

    //if no such session exists, then create one
    if(session == null)
    {
	session = SessionManagerPool.Demux.CreateSession(null, SessionType.Support, sessionName, hostName, false, sessionName, null);
    }

    //return the guest session url		
    return ServerExtensions.GetWebServerUri(ConfigurationManager.AppSettings, HttpContext.Current.Request.Url, true, true) + "?Session=" + session.SafeNav(s => s.SessionID);
}
	
public object CreateHostSupportSessionLink(string sessionName, string sessionGroupName, string hostName = null)
{
    //get a specific session within a given session group 
    var sessionGroup = SessionManagerPool.Demux.GetSessionGroups().Where(s => s.Name == sessionGroupName).First();
    var session = SessionManagerPool.Demux.GetSessions().FirstOrDefault(s => s.Name == sessionName);

    //if no such session exists, then create one
    if(session == null)
    {
	session = SessionManagerPool.Demux.CreateSession(null, SessionType.Support, sessionName, hostName, false, sessionName, null);
    }
	
    //depending on the version of the product, return the proper url
    if (Constants.ProductVersion.Major < 6)
    {
        return new Uri(ServerExtensions.GetWebServerUri(ConfigurationManager.AppSettings, HttpContext.Current.Request.Url, true, true).Uri, string.Format("Host#{0}//{1}/Join", Extensions.UrlEncode(sessionGroup.Name), session.SessionID));
    }
    else
    {
        return new Uri(ServerExtensions.GetWebServerUri(ConfigurationManager.AppSettings, HttpContext.Current.Request.Url, true, true).Uri, string.Format("Host#Support/{0}//{1}/Join", Extensions.UrlEncode(sessionGroup.Name), session.SessionID));
    }
}
ScreenConnect Team
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.