Click here to Skip to main content
15,885,141 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to use vocalocity API. for using the services,i need to authenticate the session and then need to use Active session.I am the logged in but not sure how to capture required session id.

Code to log in:
C#
String url = "https://my.vocalocity.com/appserver/rest/user/null"; 
WebRequest myReq = WebRequest.Create(url); 
String username = "xxx"; 
String password = "yyy"; 
myReq.Headers.Add("login", username); 
myReq.Headers.Add("password", password); 
WebResponse wr = myReq.GetResponse(); 
Stream receiveStream = wr.GetResponseStream(); 
StreamReader reader = new StreamReader(receiveStream, Encoding.UTF8); 
string content = reader.ReadToEnd(); 

Output json
JavaScript
content: {
  "accountId" : xxxxx,
  "userStatusID" : 1,
  "loginName" : "xxx",
  "firstName" : "xxx",
  "lastName" : "xxx",
  "email" : "xx@xx.com",
  "phoneNumber" : "123456789",
  "role" : 0,
  "roleId" : [ 3 ],
  "secretQuestionId" : 3,
  "secretAnswer" : "shyam",
  "dateLastUpdated" : "2014-10-06T18:19:35.656Z",
  "lastUpdatedByUserId" : xxxxxx,
  "existingsuperuser" : 0,
  "contactnumbers" : [ {
    "userId" : 191716,
    "contactCode" : "D",
    "contactName" : "Default Extension",
    "contactNumber" : "329"
  } ],
  "updateMeWithAnnouncements" : 0,
  "blockAccess" : 0,
  "allowEndUserOutboundCallerId" : false,
  "userId" : xxxxxx

Once the user is authenticated, a session is established and the session information will be returned in HDAP-ID and/or JSESSIONID cookies. The caller should return the cookies on subsequent requests to reuse the existing session.

Need Help in identifying HDAP-ID and/or JSESSIONID cookies and capturing the same for further use and in Deserialize of json content.
Posted
Updated 21-Apr-16 14:15pm
v2
Comments
JPartyka 11-Dec-14 8:15am    
Yes, I've identical problem. Have you resolved this issue?
Sanjeev236 23-Dec-14 0:02am    
no... Vonage has no support for this API.

I'm not sure if you already found your answer or not, but I'll chime in with what I did.

I would keep myReq (WebRequest) alive when requesting other api calls (vonage urls). Basically use the same object as you request other urls that require logging in first.
This keeps the cookie in the same session.

I use WebClient instead of WebRequest and the cookie (specifically the HDAP-ID value) is stored in webClientObj.ResponseHeaders.SetCookie
This should enable you to call the other API calls without getting the Forbidden page.

I hope this helps someone.
 
Share this answer
 
Vonage
http://businesssupport.vonage.com/ci/fattach/get/2776/0/filename/API+Guide+VBS+01282015.pdf[^]

C#
public static void ClickToCall(string user, string password, string number)
{
    const string sAuthenticationUri = "https://my.vonagebusiness.com/appserver/rest/user/null";
    const string sClickToCallUriFormat = "https://my.vonagebusiness.com/presence/rest/clicktocall/{0}";

    string sClickToCallUri = string.Format(sClickToCallUriFormat, number);

    using (WebClient oClient = new WebClient())
    {
        oClient.Headers.Add("login", user);
        oClient.Headers.Add("password", password);

        string sAuthenticationResult = oClient.DownloadString(sAuthenticationUri);
        string sClickToCallResult = oClient.DownloadString(sClickToCallUri);
    }
}
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900