-- 钉钉接口
For Each dr As DataRow In DataTables("表B").DataRows
Dim ul As String = "https://oapi.dingtalk.com/topapi/user/listsimple?access_token={0}"
Dim hc As New HttpClient(CExp(ul,Functions.Execute("access_token")))
Dim jo As New JObject
jo("dept_id") = CStr(dr("第一列"))
jo("cursor") = "0"
jo("size") = "10"
hc.Content = jo.ToString()
jo = JObject.Parse(hc.GetData())
Dim dt As DataTable = DataTables("表C")
Dim w As DataRow
If jo("errcode") = "0" Then
For Each jt As JToken In jo("result")("list")
w = dt.Find("userid = \'"& jt("userid").tostring &"\'")
If w IsNot Nothing Then
w("name") = jt("name").tostring
Else
w = dt.AddNew
w("userid") = jt("userid").tostring
w("name") = jt("name").tostring
End If
w.Save
Next
Else
MessageBox.Show(jo.ToString)
End If
Next
为什么把这段代码放到函数里面,就会显示详细错误信息:
调用的目标发生了异常。
索引超出了数组界限。