Skip to content

Instantly share code, notes, and snippets.

@AnthonyDGreen
Created March 10, 2019 01:44
Show Gist options
  • Save AnthonyDGreen/21f1467613baa3540ee7a4c8d0c2f2be to your computer and use it in GitHub Desktop.
Save AnthonyDGreen/21f1467613baa3540ee7a4c8d0c2f2be to your computer and use it in GitHub Desktop.
JsonDemo
Imports System.Net.Http
Imports Newtonsoft.Json.Linq
Module RestDemo
Async Function RunAsync() As Task
Dim client As New HttpClient With {.BaseAddress = New Uri("https://api.github.com")}
#Region " Initialize HttpClient headers "
With client.DefaultRequestHeaders
.UserAgent.Add("JsonDemo", "0.1")
.Accept.Add("application/json")
.Authorization.Set("Token", My.Settings.AccessToken)
End With
#End Region
Dim gist =
{
"description": My.Application.Info.AssemblyName,
"public": true,
"files": {
"RestDemo.vb": {
"content": IO.File.ReadAllText("..\..\RestDemo.vb")
}
}
}
Dim response = Await client.PostJsonAsync("/gists", gist)
Console.WriteLine(response)
End Function
End Module
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment