以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  执行代码错,在别机子代码问题的,缺少了什么?  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=169205)

--  作者:gudao123456
--  发布时间:2021/6/7 11:01:00
--  执行代码错,在别机子代码问题的,缺少了什么?
在家里的机子一切正常,到办公室后执
图片点击可在新窗口打开查看此主题相关图片如下:d9mxc%x%}nbxbrsiz_aty.png
图片点击可在新窗口打开查看
行就出错了,是系统缺少什么程序吗?
--  作者:有点蓝
--  发布时间:2021/6/7 11:07:00
--  
什么代码?
--  作者:gudao123456
--  发布时间:2021/6/7 11:14:00
--  
Dim access_token As String =Functions.Execute("access_token")   
Dim id As String ="1"   \' args(1)


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.Id = "1"
req.SetHttpMethod("GET")
Dim rsp As DingTalk.Api.Response.OapiDepartmentListResponse  = client.Execute(req, access_token)


Dim jo As JObject = JObject.Parse(rsp.body)
Dim ja As JArray = jo("department")
Dim dr As DataRow
For i As Integer = 0 To ja.Count - 1
    dr = DataTables("departmentlist").Find("部门ID = \'" & ja(i)("id").Tostring & "\'")
    If dr Is Nothing Then
        dr=DataTables("departmentlist").addnew()
        dr("部门名称")=ja(i)("name")
        dr("部门ID")=ja(i)("id").Tostring
        dr.save()
    
    End If
Next

代码应该没问题,昨晚在家都很正常的,是否是运行环境缺少点什么,谢谢!
[此贴子已经被作者于2021/6/7 11:15:36编辑过]

--  作者:gudao123456
--  发布时间:2021/6/7 11:18:00
--  
Dim access_token As String =Functions.Execute("access_token")   
Dim id As String ="1"   \' args(1)


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.Id = "1"
req.SetHttpMethod("GET")
Dim rsp As DingTalk.Api.Response.OapiDepartmentListResponse  = client.Execute(req, access_token)


Dim jo As JObject = JObject.Parse(rsp.body)
Dim ja As JArray = jo("department")
Dim dr As DataRow
For i As Integer = 0 To ja.Count - 1
    dr = DataTables("departmentlist").Find("部门ID = \'" & ja(i)("id").Tostring & "\'")
    If dr Is Nothing Then
        dr=DataTables("departmentlist").addnew()
        dr("部门名称")=ja(i)("name")
        dr("部门ID")=ja(i)("id").Tostring
        dr.save()
    
    End If
Next

代码应该没问题,函数:Functions.Execute("access_token") ,没有问题,单独执行是可以有结果的。昨晚在家都很正常的,是否是运行环境缺少点什么,谢谢!

[此贴子已经被作者于2021/6/7 11:20:37编辑过]

--  作者:有点蓝
--  发布时间:2021/6/7 11:19:00
--  
调试一下,具体哪一句代码出错

出错的时候msgbox(rsp.Body)显示什么内容?

--  作者:gudao123456
--  发布时间:2021/6/7 11:26:00
--  
谢谢!在你指引下查看msgbox(rsp.Body)显示内容,找到原因了,是需要另外添加一个IP进白名单中,谢谢!