我需要在URL中包含curl -H 'Context-type:application/json',但不确定如何实现。目前服务器响应为404,非常感谢任何帮助。
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;
}
}