public async Task <IHttpActionResult> GetBusDynamic(string cityEN, string routeName) { //Initial IHttpActionResult responseResult; DateTime now = DateTime.Now; IBusDynamic repos = DataFactory.BusDynamicRepository(); //Setting target Url string targetURI = ConfigurationManager.AppSettings["BusDynamicInfoURL"].ToString() + "/" + cityEN + "/" + routeName + "?$format=JSON"; HttpClient client = new HttpClient(); client.MaxResponseContentBufferSize = Int32.MaxValue; //Get Json String var response = await client.GetStringAsync(targetURI); //Deserialize var collection = JsonConvert.DeserializeObject <IEnumerable <BusDynamicDeserialize> >(response); //將需要的欄位取出後序列化 var jsonSerialize = JsonConvert.SerializeObject(repos.GetBusDynamicInfo(collection)); //做成JSON字串包裝到最後輸出 StringContent responseMsgString = new StringContent(jsonSerialize, System.Text.Encoding.UTF8, "application/json"); HttpResponseMessage responseMsg = new HttpResponseMessage() { Content = responseMsgString }; responseResult = ResponseMessage(responseMsg); return(responseResult); }