//// 建立連線
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();
沒有留言:
張貼留言