Tot nu toe werkte de code gewoon, sinds gisteren (mogelijk eerder) niet meer.
De code in C#:
WebRequest request = WebRequest.Create(strUrl);
request.Headers.Add("x-api-key", X_Api_Key);
// Zet een time-out op 10 sec.
request.Timeout = iTimeOut;
Stream newStream = null;
if (strData.Length > 0)
{
request.Method = "POST";
byte[] byteArray = Encoding.UTF8.GetBytes(strData);
// Set the content type of the data being posted.
request.ContentType = "application/x-www-form-urlencoded";
// Set the content length of the string being posted.
request.ContentLength = byteArray.Length;
newStream = request.GetRequestStream();
newStream.Write(byteArray, 0, byteArray.Length);
}
// Get the response.
string strResult = string.Empty;
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Daarin is
strUrl: https://bag.basisregistraties.overheid.nl/api/v1/panden
X_Api_Key: de unique key, die ik hier niet wil melden
strData: { “geometrie”: { “contains”: { “type”: “Point”, “coordinates”: [ 5.416337 , 52.164485 ] } } }
BAG API is recent naar een nieuw backend gemigreerd.
Lijkt erop dat het oude backend nooit de waarde van de Content-Type header heeft gevalideerd; dit doet het huidige backend wel.