【问题标题】:Square API with Vb.net带有 Vb.net 的 Square API
【发布时间】:2016-07-18 04:34:46
【问题描述】:
Dim myUri = New Uri("https://squareup.com/v2/locations")

Dim RQ As HttpWebRequest = TryCast(WebRequest.Create(myUri), HttpWebRequest)

RQ.PreAuthenticate = True    
RQ.Headers.Add("Authorization", "Bearer" & Token) '''Token is a Shared string assigned to my current Access Token
RQ.Method = "GET"
RQ.Accept = "application/json"
RQ.ContentType = "application/json"


Using response As HttpWebResponse = TryCast(RQ.GetResponse(), HttpWebResponse) '''''"The remote server returned an error: (404) Not Found."

Square-Connect API 非常新,并且没有 vb.net 示例,所以这是我所能得到的。我无法通过最后一行。无论我尝试什么,我总是会收到 404 错误。任何人都知道为什么。

如果我在终端中使用这个命令(用我的访问令牌替换令牌),那么我会在 vb.net 中得到我想要的结果。

curl -H "Authorization: Bearer Token" https://connect.squareup.com/v2/locations

【问题讨论】:

    标签: vb.net-2010 square-connect


    【解决方案1】:

    广场上的人很快发现了我的问题,所以这里是工作代码:

     Dim myUri = New Uri("https://connect.squareup.com/v2/locations")
        Dim RQ As HttpWebRequest = TryCast(WebRequest.Create(myUri), HttpWebRequest)
    
        RQ.PreAuthenticate = True
        RQ.Headers.Add("Authorization", "Bearer " + Token) 'Token is a Shared string assigned to my current Access Token
        RQ.Method = "GET"
        RQ.Accept = "application/json"
        RQ.ContentType = "application/json"
    
    
        Using response As HttpWebResponse = TryCast(RQ.GetResponse(), HttpWebResponse)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-11-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-06-30
      • 2018-08-03
      • 1970-01-01
      相关资源
      最近更新 更多