Solved! Go to Solution.
public string AddRasterToArcGISServer(string ArcGISImageServerURL, string RasterItemID) { Uri address = new Uri(ArcGISImageServerURL + "/add"); // Create the web request HttpWebRequest request = WebRequest.Create(address) as HttpWebRequest; // Set type to POST request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded"; // Create the data we want to send string itemIds = RasterItemID; string rasterType = "Raster Dataset"; StringBuilder data = new StringBuilder(); data.Append("itemIds=" + HttpUtility.UrlEncode(itemIds)); data.Append("&rasterType=" + HttpUtility.UrlEncode(rasterType)); // Create a byte array of the data we want to send byte[] byteData = UTF8Encoding.UTF8.GetBytes(data.ToString()); // Set the content length in the request headers request.ContentLength = byteData.Length; // Write data using (Stream postStream = request.GetRequestStream()) { postStream.Write(byteData, 0, byteData.Length); } string functionResponse = ""; // Get response using (HttpWebResponse response = request.GetResponse() as HttpWebResponse) { // Get the response stream StreamReader reader = new StreamReader(response.GetResponseStream()); // Console application output functionResponse = reader.ReadToEnd(); } return functionResponse; }
public string AddRasterToArcGISServer(string ArcGISImageServerURL, string RasterItemID) { Uri address = new Uri(ArcGISImageServerURL + "/add"); // Create the web request HttpWebRequest request = WebRequest.Create(address) as HttpWebRequest; // Set type to POST request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded"; // Create the data we want to send string itemIds = RasterItemID; string rasterType = "Raster Dataset"; StringBuilder data = new StringBuilder(); data.Append("itemIds=" + HttpUtility.UrlEncode(itemIds)); data.Append("&rasterType=" + HttpUtility.UrlEncode(rasterType)); // Create a byte array of the data we want to send byte[] byteData = UTF8Encoding.UTF8.GetBytes(data.ToString()); // Set the content length in the request headers request.ContentLength = byteData.Length; // Write data using (Stream postStream = request.GetRequestStream()) { postStream.Write(byteData, 0, byteData.Length); } string functionResponse = ""; // Get response using (HttpWebResponse response = request.GetResponse() as HttpWebResponse) { // Get the response stream StreamReader reader = new StreamReader(response.GetResponseStream()); // Console application output functionResponse = reader.ReadToEnd(); } return functionResponse; }