Dim client As DingTalk.Api.IDingTalkClient = New DingTalk.Api.DefaultDingTalkClient("https://oapi.dingtalk.com/department/list")
Dim req As DingTalk.Api.Request.OapiDepartmentListRequest = New DingTalk.Api.Request.OapiDepartmentListRequest()
req.SetHttpMethod("GET")
Dim rsp As DingTalk.Api.Response.OapiDepartmentListResponse = client.Execute(req, access_token)
DataTables("表B").DataRows.Clear
For i As Integer = 0 To rsp.Department.count -1
Dim r As Row
r = Tables("表B").AddNew
r("第一列") = rsp.Department.Item(I).id
r("第二列") = rsp.Department.Item(I).name
r("第三列") = rsp.Department.Item(I).Parentid
Next
DataTables("表B").Save
MessageBox.Show("读取完成")
上面的是用钉钉提供的sdk获取到的所有部门信息
Dim ul As String = "https://oapi.dingtalk.com/department/list?access_token={0}"
Dim hc As New HttpClient(CExp(ul,Functions.Execute("access_token")))
Dim jo As JObject = JObject.Parse(hc.GetData())
If jo("errcode") = "0" Then
MessageBox.Show("成功")
Else
MessageBox.Show(jo.ToString)
End If
怎么用上面这种获取所有部门信息呢?红色的部分不知道该怎么实现?获取到的只有根部门,不是所有部门,要获得所有部门必须提供父部门dept_id
[此贴子已经被作者于2021/12/1 2:09:40编辑过]