【问题标题】:401 Unauthorised Access error using Shopify API in VB.Net在 VB.Net 中使用 Shopify API 出现 401 未经授权的访问错误
【发布时间】:2014-05-24 05:20:59
【问题描述】:

我正在尝试连接到 VB.NET 中的 Shopify API 并下载一些 json 订单信息,但每次尝试我都会收到“401 未授权访问”错误。我用来实现这一点的代码如下:

    '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),但我不知道如何实施。如果有人能够提供帮助,将不胜感激。

【问题讨论】:

  • 我无法找到类似的 shopify URL 调用示例。你有没有考虑过使用他们的.NET API

标签: json vb.net api oauth shopify


【解决方案1】:

试试:

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)

【讨论】:

    猜你喜欢
    • 2022-01-03
    • 1970-01-01
    • 2020-12-17
    • 2022-11-09
    • 1970-01-01
    • 2011-09-15
    • 1970-01-01
    • 2016-01-30
    • 2020-06-19
    相关资源
    最近更新 更多