Function GetShop() As String
Try
ServicePointManager.Expect100Continue = True
'needed to upgrade my project to .NET 4.5.1 to have this available
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12
'passing in the machine name makes the examples easier to code and publish
Dim UserName As String = "xxxxxxxx"
Dim Password As String = "xxxxxxx"
Dim Shop As String = "myshop" ' the name of your shop (myshop.myshopify.com)
Dim APIVersion As String = "2019-10" 'the latest API as of this date
'this is the endpoint that we're going to test, it is the simplest one to call; it will return information about the shop
Dim Resource As String = String.Format("shop")
'form the url
Dim strUrl As String = String.Format("https://{2}.myshopify.com/admin/api/{3}/{4}.json", UserName, Password, Shop, APIVersion, Resource)
Dim oRequest As System.Net.HttpWebRequest
Dim oResponse As System.Net.WebResponse = Nothing
' Create the web request
oRequest = DirectCast(System.Net.WebRequest.Create(strUrl), System.Net.HttpWebRequest)
oRequest.Method = "GET"
oRequest.ContentType = "application/json"
' Add authentication to request
oRequest.Credentials = New System.Net.NetworkCredential(UserName, Password)
' Get the response
oResponse = DirectCast(oRequest.GetResponse(), System.Net.WebResponse)
'convert the response to a Stream
Dim oStream As System.IO.Stream = oResponse.GetResponseStream()
'convert the Stream to a StreamReader
Dim oStreamReader As New System.IO.StreamReader(oStream)
'read the response into a String
Dim strResponse As String = oStreamReader.ReadToEnd
Catch ex As Exception
MsgBox(ex.Message)
End Try
Return ""
End Function