Try to get a new order for your restaurant from the Thuisbezorgd API with vb.net: simple 🙂
Create a WebRequest
Add some Authentication
Add the API key
run the GetRequest()
The server committed a protocol violation. Section=ResponseHeader Detail=CR must be followed by LF
So what is it?
And get to the solution of adding some code to get the WebRequest accept the response from the server:
Imports System.Reflection Sub SetAllowUnsafeHeaderParsing20() Dim a As New System.Net.Configuration.SettingsSection Dim type As Type = GetType(System.Net.Configuration.SettingsSection) Dim aNetAssembly As System.Reflection.Assembly = Assembly.GetAssembly(type) Dim aSettingsType As Type = aNetAssembly.GetType("System.Net.Configuration.SettingsSectionInternal") Dim args As Object() Dim anInstance As Object = aSettingsType.InvokeMember("Section", BindingFlags.Static Or BindingFlags.GetProperty Or BindingFlags.NonPublic, Nothing, Nothing, args) Dim aUseUnsafeHeaderParsing As FieldInfo = aSettingsType.GetField("useUnsafeHeaderParsing", BindingFlags.NonPublic Or BindingFlags.Instance) aUseUnsafeHeaderParsing.SetValue(anInstance, True) End Sub
Call this before you read the WebRequest, with WebRequestObject.GetResponse(), and all should be fine.
Of course the real problem is with on the server-side, but trying to get the end-point to change is harder than having your code ignoring the issue in the first place. Not correct, but at least: problem solved!
Have a nice day!