Beispiel #1
0
        public string DoHandshake(out string outPostData)
        {
            string strResponse = string.Empty;

            restClient.httpMethod = httpMethod.POST;
            restClient.URI        = URL_SXS;

            JsonHandshake jHandshake  = new JsonHandshake(PRODUCT_ID, APIKEY);
            string        strPostData = JsonConvert.SerializeObject(jHandshake, Formatting.Indented);

            // return generated PostData to out string
            outPostData = strPostData;

            strResponse = restClient.PostRequest(strPostData);


            // Using Newtonsoft.Json library to do JSON Deserialization Object
            try
            {
                // Beautify Json response
                strResponse = JValue.Parse(strResponse).ToString(Formatting.Indented);


                var myObject = JsonConvert.DeserializeObject <dynamic>(strResponse);

                if (myObject.isSuccess == true)
                {
                    SESSIONTOKEN       = myObject.sessionToken;
                    ISHANDSHAKESUCCESS = true;
                    APPNAME            = myObject.info.appName;
                }
                else
                {
                    SESSIONTOKEN       = "";
                    ISHANDSHAKESUCCESS = false;
                    DebugOutput("ERROR");
                }
            }
            catch (Exception)
            {
                //strResponse = ex.Message.ToString();
            }


            return(strResponse);
        }
Beispiel #2
0
        public string DoHandshake()
        {
            string strResponse = string.Empty;

            restClient.httpMethod = httpMethod.POST;
            restClient.URI        = URL_SXS;

            JsonHandshake jHandshake  = new JsonHandshake(PRODUCT_ID, APIKEY);
            string        strPostData = JsonConvert.SerializeObject(jHandshake);

            strResponse = restClient.PostRequest(strPostData);

            // Using Newtonsoft.Json library to do JSON Deserialization Object
            try
            {
                var myObject = JsonConvert.DeserializeObject <dynamic>(strResponse);

                if (myObject.isSuccess == true)
                {
                    SESSIONTOKEN       = myObject.sessionToken;
                    ISHANDSHAKESUCCESS = true;
                }
                else
                {
                    SESSIONTOKEN       = "";
                    ISHANDSHAKESUCCESS = false;
                    DebugOutput("ERROR");
                }
            }
            catch (Exception ex)
            {
                strResponse = ex.Message.ToString();
            }


            return(strResponse);
        }