Forum Cross Platform with Xamarin

Announcement:

The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

Add Custom Header to WebRequest

I am trying to send http request via https in cross platform project with shared projects. So far i have tried WebClient and WebRequest classes. WebCLient doesn't allow custom headers. With Web Request when i add header:

HttpWebRequest req = HttpWebRequest.CreateHttp( "https://www.google.com" );
req.Headers["Content-Type"] = "application/json";

I get TargetInvocationError( java.lang exception ).

Do you how this can be achieved in a cross-platform fashion.

Answers

Sign In or Register to comment.