Json 401在VB.Net中使用Shopify API时出现未经授权的访问错误
我试图连接到VB.NET中的Shopify API并下载一些json订单信息,但每次尝试都会出现“401未经授权访问”错误。我使用的代码如下所示:Json 401在VB.Net中使用Shopify API时出现未经授权的访问错误,json,vb.net,api,oauth,shopify,Json,Vb.net,Api,Oauth,Shopify,我试图连接到VB.NET中的Shopify API并下载一些json订单信息,但每次尝试都会出现“401未经授权访问”错误。我使用的代码如下所示: 'Develop API string to get orders Dim url As String url = "https://" & apikey & ":" & apipassword & "@" & domain & "/admin/orders.json"
'Develop API string to get orders
Dim url As String
url = "https://" & apikey & ":" & apipassword & "@" & domain & "/admin/orders.json"
'Create new web service connection
Dim ws As New WebClient()
'Get json data from remote Shopify server
Dim json_data As String
Try
json_data = ws.DownloadString(url)
Catch ex As Exception
MsgBox("Connection to the remote server failed! Please check your internet connection or contact the developer.", vbOKOnly, "Connection Failed")
Exit Sub
End Try
我知道Shopify使用另一个级别的授权(OAuth),但我不知道如何实现这一点。如果有人能帮忙,我们将不胜感激。试试:
Dim request As WebRequest = WebRequest.Create("https://shop.myshopify.com/admin/orders.json")
request.Credentials = New NetworkCredential("apikey", "password")
Dim response As HttpWebResponse = DirectCast(request.GetResponse(), HttpWebResponse)
我很难找到类似shopify URL调用的示例。你考虑过使用他们的软件吗