상속: System.Net.WebClient
예제 #1
0
 public string CallApiForDelete(String apiEndPoint, string accessToken)
 {
     var webClient = new ExtendedWebClient();
     Trace.TraceInformation(string.Format("CallApiForDelete: {0}", apiEndPoint));
     webClient.Headers.Add("Authorization", string.Format("bearer {0}", accessToken));
     webClient.Headers.Add("Content-Type", "application/vnd.inbloom+json");
     webClient.Headers.Add("Accept", "application/vnd.inbloom+json");
     return webClient.UploadString(apiEndPoint, "DELETE");
 }
예제 #2
0
 public string CallApiForPost(string apiEndPoint, string accessToken, string data)
 {
     var webClient = new ExtendedWebClient();
     Trace.TraceInformation(string.Format("CallApiForPost: {0}", apiEndPoint));
     webClient.Headers.Add("Authorization", string.Format("bearer {0}", accessToken));
     webClient.Headers.Add("Content-Type", "application/vnd.slc+json");
     webClient.Headers.Add("Accept", "application/vnd.slc+json");
     return webClient.UploadString(apiEndPoint, "POST", data);
 }
예제 #3
0
		private static ExtendedWebClient GetExtendedWebClient(string accessToken, RequestType requestType)
		{
			var restClient = new ExtendedWebClient();

			string bearerToken = string.Format("bearer {0}", accessToken);

			restClient.Headers.Add("Authorization", bearerToken);

			if (requestType == RequestType.Xml)
			{
				restClient.Headers.Add("Content-Type", "application/vnd.slc+json");
				restClient.Headers.Add("Accept", "application/vnd.slc+xml");
			}
			else
			{
				restClient.Headers.Add("Content-Type", "application/vnd.slc+json");
				restClient.Headers.Add("Accept", "application/vnd.slc+json");
			}

			return restClient;
		}