2018年2月28日 星期三

C# Http Request

//// 建立連線
WebRequest request = WebRequest.Create(requestUrl);

//// 定義連線資訊
request.Method = "POST";
request.ContentType = "application/json";
request.Headers.Add("Authorization", "Bearer " + token);

//// FormData
StreamWriter streamWriter = new StreamWriter(request.GetRequestStream());
streamWriter.Write(parameter);
streamWriter.Flush();
streamWriter.Close();

//// 回應資訊
WebResponse response = request.GetResponse();
Stream dataStream = response.GetResponseStream();
StreamReader reader = new StreamReader(dataStream);
string responseFromServer = reader.ReadToEnd();

//// Close
reader.Close();
response.Close();

remove last word from SQL query

SET @columnSql = SUBSTRING ( @columnSql , 1 , LEN ( @columnSql ) - 1 )