private static string GetDecodedUrlAsString(string codecEndpoint) { // Create a WebRequest session to the endpoint WebRequest request = WebRequest.Create(codecEndpoint); // Get the response. WebResponse response = request.GetResponse(); // Get the stream containing content returned by the server. Stream dataStream = response.GetResponseStream(); // Open the stream using a StreamReader for easy access. //StreamReader reader = new StreamReader(dataStream); //var jsonResponseString = serializer.DeserializeObject(reader.ReadToEnd()); DecodeResponse responseObject = new DecodeResponse(); DataContractJsonSerializer serializer = new DataContractJsonSerializer(responseObject.GetType()); responseObject = serializer.ReadObject(dataStream) as DecodeResponse; string redirectUrl = responseObject.Url; // Read the content and return string. return(redirectUrl); }
public DecodeResponse Get(string id) { DecodeResponse response = new DecodeResponse(DataAccess.RetrieveUrl(id)); return(response); }