這是一個相當大的主題,但它是最簡單的,你可以試試這個...
Imports System.Net
然後......
Dim wHeader As WebHeaderCollection = New WebHeaderCollection()
wHeader.Clear()
wHeader.Add("Authorization: Bearer 0da6cf0d-848c-4266-9b47-cd32a6151b1f")
wHeader.Add("Assume-User: john.doe%40smartsheet.com")
Dim sUrl As String = "https://api.smartsheet.com/1.0/sheets"
Dim wRequest As HttpWebRequest = DirectCast(System.Net.HttpWebRequest.Create(sUrl), HttpWebRequest)
'wRequest.ContentType = "application/json" ' I don't know what your content type is
wRequest.Headers = wHeader
wRequest.Method = "GET"
Dim wResponse As HttpWebResponse = DirectCast(wRequest.GetResponse(), HttpWebResponse)
Dim sResponse As String = ""
Using srRead As New StreamReader(wResponse.GetResponseStream())
sResponse = srRead.ReadToEnd()
End Using
我不熟悉的smartsheet API,但你可以用它作爲一個起點。
如果您使用的是代理,你將需要添加...
Dim wProxy As IWebProxy = WebRequest.GetSystemWebProxy()
wProxy.Credentials = System.Net.CredentialCache.DefaultCredentials
並指定代理時,你的請求......
wRequest.Proxy = wProxy
謝謝夏蘭。當我嘗試了你的兩個代碼時,我收到錯誤「遠程服務器返回錯誤:(401)未經授權」。這與令牌有關嗎? – 2013-02-12 16:13:42
您是未經授權的,我很害怕,即您被拒絕訪問。你是否有密碼提供在標題以及你的用戶?再次查看您的智能表文檔並查看您提供憑據的位置 – 2013-02-12 16:19:42
是的,我已經自己生成了令牌並提供了我的電子郵件地址。我已經使用這個文檔http://www.smartsheet.com/developers/api-documentation#h.3bqgetcbgx89 – 2013-02-12 16:21:56