Last active
March 29, 2019 07:06
-
-
Save RahulJyala7/3eb4f4c5280e4e50ca62e630bc24e5f6 to your computer and use it in GitHub Desktop.
Protobuff Custom Formatter in Web Api C#
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| byte[] rawBytes = ProtoBufSerializer.ProtoSerialize<LoginRequest>(loginRequest); | |
| var client = new HttpClient(); | |
| client.BaseAddress = new Uri("http://localhost/"); | |
| client.DefaultRequestHeaders.Accept.Add( | |
| new MediaTypeWithQualityHeaderValue("application/x-protobuf")); | |
| var byteArrayContent = new ByteArrayContent(rawBytes); | |
| byteArrayContent.Headers.ContentType = new MediaTypeHeaderValue("application/x-protobuf"); | |
| var result = client.PostAsync("Api/Login", byteArrayContent).Result; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment