public override ResponseMessage RunDataService(RequestMessage requestMessage) { using(var client = new WebClient()) { var requestBytes = DataServiceTool.ResolveRequestSerializer(ProductName).Serialize(requestMessage); var responseText = client.UploadStringTask(GetScriptUrl(), "POST", requestBytes.Base64Encode()).Result; return DataServiceTool.ResolveResponseSerializer(ProductName).Deserialize(responseText.Base64Decode()); } }
/// <summary>Uploads data in a string to the specified resource, asynchronously.</summary> /// <param name="webClient">The WebClient.</param> /// <param name="address">The URI to which the data should be uploaded.</param> /// <param name="method">The HTTP method that should be used to upload the data.</param> /// <param name="data">The data to upload.</param> /// <returns>A Task containing the data in the response from the upload.</returns> public static Task <string> UploadStringTask(this WebClient webClient, string address, string method, string data) { return(webClient.UploadStringTask(new Uri(address), method, data)); }