//You may wish to replace this code with your preferred library for posting and receiving JSON data.
        private static CreateSessionTokenResponse MakeWebRequest(string requestUrl, CreateSessionTokenRequest request)
        {
            var webRequest = WebRequest.Create(requestUrl) as HttpWebRequest;

            webRequest.Method      = "POST";
            webRequest.ContentType = "application/json";

            var jsonSerializer = new JavaScriptSerializer();
            var requestStr     = jsonSerializer.Serialize(request);

            Debug.WriteLine(requestStr);

            using (var writer = new StreamWriter(webRequest.GetRequestStream()))
            {
                writer.Write(requestStr);
                writer.Close();
            }

            var response = webRequest.GetResponse() as HttpWebResponse;

            string jsonResult;

            using (var reader = new StreamReader(response.GetResponseStream()))
            {
                jsonResult = reader.ReadToEnd();
                reader.Close();
            }

            Debug.WriteLine(jsonResult);

            return(jsonSerializer.Deserialize <CreateSessionTokenResponse>(jsonResult));
        }
        public CreateSessionTokenResponse GetCreateSessionResponse()
        {
            const string createSessionRequestUrl  = "https://connect.gettyimages.com/v1/session/CreateSession";
            var          createSessionRequestBody = new CreateSessionRequestBody
            {
                SystemId       = ConfigurationSettings.AppSettings["systemId"].ToString(),
                SystemPassword = ConfigurationSettings.AppSettings["syspassword"].ToString(),
                UserName       = ConfigurationSettings.AppSettings["Username"].ToString(),
                UserPassword   = ConfigurationSettings.AppSettings["Password"].ToString(),
            };

            var createSessionTokenRequest = new CreateSessionTokenRequest
            {
                RequestHeader            = new RequestHeader(),
                CreateSessionRequestBody = createSessionRequestBody
            };

            return(MakeWebRequest(createSessionRequestUrl, createSessionTokenRequest));
        }
Example #3
0
        public CreateSessionTokenResponse GetCreateSessionResponse()
        {
            const string createSessionRequestUrl  = "https://connect.gettyimages.com/v1/session/CreateSession";
            var          createSessionRequestBody = new CreateSessionRequestBody
            {
                SystemId       = "systemId",
                SystemPassword = "******",
                UserName       = "******",
                UserPassword   = "******",
            };

            var createSessionTokenRequest = new CreateSessionTokenRequest
            {
                RequestHeader            = new RequestHeader(),
                CreateSessionRequestBody = createSessionRequestBody
            };

            return(MakeWebRequest(createSessionRequestUrl, createSessionTokenRequest));
        }
        //You may wish to replace this code with your preferred library for posting and receiving JSON data.
        private static CreateSessionTokenResponse MakeWebRequest(string requestUrl, CreateSessionTokenRequest request)
        {
            var webRequest = WebRequest.Create(requestUrl) as HttpWebRequest;

            webRequest.Method = "POST";
            webRequest.ContentType = "application/json";

            var jsonSerializer = new JavaScriptSerializer();
            var requestStr = jsonSerializer.Serialize(request);

            Debug.WriteLine(requestStr);

            using (var writer = new StreamWriter(webRequest.GetRequestStream()))
            {
                writer.Write(requestStr);
                writer.Close();
            }

            var response = webRequest.GetResponse() as HttpWebResponse;

            string jsonResult;
            using (var reader = new StreamReader(response.GetResponseStream()))
            {
                jsonResult = reader.ReadToEnd();
                reader.Close();
            }

            Debug.WriteLine(jsonResult);

            return jsonSerializer.Deserialize<CreateSessionTokenResponse>(jsonResult);
        }
        public CreateSessionTokenResponse GetCreateSessionResponse()
        {
            const string createSessionRequestUrl = "https://connect.gettyimages.com/v1/session/CreateSession";
            var createSessionRequestBody = new CreateSessionRequestBody
            {
                SystemId = "systemId",
                SystemPassword = "******",
                UserName = "******",
                UserPassword = "******",
            };

            var createSessionTokenRequest = new CreateSessionTokenRequest
            {
                RequestHeader = new RequestHeader(),
                CreateSessionRequestBody = createSessionRequestBody
            };

            return MakeWebRequest(createSessionRequestUrl, createSessionTokenRequest);            
        }