3
url에 curl -H 'Context-type : application/json'을 포함시켜야합니다. 서버에서 응답하는 방법을 지금까지 404 번까지 알려 주셨습니다.GET RESTful 요청을 만드는 방법
private string RequestVehicleData()
{
string make = "";
string postcode = "";
string registration = (string)(Session["regNo"]);
make = txtmake.Text;
postcode = txtpostcode.Text;
//Make Request
var httpWebRequest = (HttpWebRequest)WebRequest.Create(string.Format("https://www.check-mot.service.gov.uk/api/v1/mot-history/{0}/{1}/", registration, make));
httpWebRequest.ContentType = "application/json";
httpWebRequest.Method = "GET";
//Get Response
var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
var result = streamReader.ReadToEnd();
return result;
}
}
가능한 복제 [? C 번호에 HttpWebRequest를의 내용을 설정하는 방법 (http://stackoverflow.com/questions/5527316/how-to-set -the-content-of-an-http-http-b-c) –