curl命令到HTML或vb.net [英] Curl command to html or vb.net
问题描述
我试图访问smartsheet API。他们在袅袅提供了一个示例code来访问它。
I am trying to access the smartsheet API. They have a sample code provided in curl to access it.
要访问您的工作表列表,用你喜欢的编程语言或脚本语言构建的HTTPS请求。下面是使用卷曲从Linux命令行的例子:
To access your Sheet list, construct an HTTPS request using your favorite programming or scripting language. Here is an example using the curl from a linux command line:
curl https://api.smartsheet.com/1.0/sheets \
-H "Authorization: Bearer 0da6cf0d-848c-4266-9b47-cd32a6151b1f" \
-H "Assume-User: john.doe%40smartsheet.com"
我如何做,在vb.net或HTML表单?
How do I do that in vb.net or from a html form?
推荐答案
这是一个相当大的主题,但它是最简单的,你可以试试这个...
This is a rather large subject but at it's most simple you could try this...
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,但你可以使用它作为一个起点。
I'm unfamiliar with the smartsheet API but you can use this as a start point.
如果您使用的是代理,你将需要添加...
If you are using a Proxy you will need to add...
Dim wProxy As IWebProxy = WebRequest.GetSystemWebProxy()
wProxy.Credentials = System.Net.CredentialCache.DefaultCredentials
和指定代理时,你的请求......
and specify the proxy when you make the request...
wRequest.Proxy = wProxy
这篇关于curl命令到HTML或vb.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!