Hi Steve,
Use OnBeforeRequestAdvanced event instead of OnBeforeRequest event.
OnBeforeRequest event is used to customize request like changing the URL, Headers etc at runtime
OnBeforeRequestAdvanced is used to add some customize .net code to request and you are adding a extension a .net extension RESTProxy to add the Proxy in HttpRequest
By seeing the code it seems like the below code is returning null object in OnBeforeRequest as the request is not yet initialized.

Best Regards
Devendra