我对 Smartsheet 和使用 c# 编程很陌生。大多数是初学者并尝试使用 Visual Studio 2013 将我的 Web 应用程序与 Smartsheet 集成。我目前正在努力让 gridview 控件填充来自 Smartsheet(json 格式)的返回数据。到目前为止,我已经能够获得包含以下内容的 json 字符串:
{
"id":4705121406871428,
"name":"Distributors",
"version":3,
"totalRowCount":2,
"accessLevel":"OWNER",
"effectiveAttachmentOptions":[
"DROPBOX",
"GOOGLE_DRIVE",
"BOX_COM",
"FILE"
],
"ganttEnabled":false,
"dependenciesEnabled":false,
"permalink":"https://app.smartsheet.com/b/home?lx=xlJ7OtqknyOndgOnClj4qg",
"createdAt":"2015-06-22T16:55:02+10:00",
"modifiedAt":"2015-06-23T14:17:47+10:00",
"columns":[
{
"id":3238895438587780,
"index":0,
"title":"id",
"type":"TEXT_NUMBER",
"primary":true,
"width":150
},
{
"id":7742495065958276,
"index":1,
"title":"distName",
"type":"TEXT_NUMBER",
"width":150
},
{
"id":2112995531745156,
"index":2,
"title":"agency",
"type":"TEXT_NUMBER",
"width":150
},
{
"id":6616595159115652,
"index":3,
"title":"profile",
"type":"TEXT_NUMBER",
"width":150
}
],
"rows":[
{
"id":3999757174630276,
"rowNumber":1,
"expanded":true,
"createdAt":"2015-06-23T11:05:26+10:00",
"modifiedAt":"2015-06-23T14:17:47+10:00",
"cells":[
{
"columnId":3238895438587780,
"type":"TEXT_NUMBER",
"value":1.0,
"displayValue":"1"
},
{
"columnId":7742495065958276,
"type":"TEXT_NUMBER",
"value":"ABS",
"displayValue":"ABS"
},
{
"columnId":2112995531745156,
"type":"TEXT_NUMBER",
"value":"ShedsRus",
"displayValue":"ShedsRus"
},
{
"columnId":6616595159115652,
"type":"TEXT_NUMBER",
"value":"OK",
"displayValue":"OK"
}
]
},
{
"id":8503356802000772,
"rowNumber":2,
"siblingId":3999757174630276,
"expanded":true,
"createdAt":"2015-06-23T11:05:26+10:00",
"modifiedAt":"2015-06-23T14:17:47+10:00",
"cells":[
{
"columnId":3238895438587780,
"type":"TEXT_NUMBER",
"value":2.0,
"displayValue":"2"
},
{
"columnId":7742495065958276,
"type":"TEXT_NUMBER",
"value":"Barns",
"displayValue":"Barns"
},
{
"columnId":2112995531745156,
"type":"TEXT_NUMBER",
"value":"BarnsRus",
"displayValue":"BarnsRus"
},
{
"columnId":6616595159115652,
"type":"TEXT_NUMBER",
"value":"OK",
"displayValue":"OK"
}
]
}
]
}
该字符串看起来包含太多信息,例如 id 和类型等...我想要的只是我的列名及其相关数据。然后,将此信息显示为 gridview 控件。
这是我的 json 请求:
string sURL;
sURL = "https://api.smartsheet.com/1.1/sheet/4705121406871428";
WebRequest wrGETURL;
wrGETURL = WebRequest.Create(sURL);
wrGETURL.ContentType = "application/json";
wrGETURL.Method = "GET";
wrGETURL.Headers["Authorization"] = "Bearer ******************";
Stream objStream;
objStream = wrGETURL.GetResponse().GetResponseStream();
StreamReader objReader = new StreamReader(objStream);
string jsonResult = objReader.ReadToEnd();
如果有人可以提供一些指导来帮助我完成这项工作,将不胜感激......请原谅我对这个话题的完全无知......在这里完成新手!谢谢。