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;
}
}
の可能性のある重複(http://stackoverflow.com/questions/5527316/how-to-set -the-of-a-http-b-c) –