以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  钉钉新版服务端API使用问题  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=177537)

--  作者:z769036165
--  发布时间:2022/5/26 10:07:00
--  钉钉新版服务端API使用问题
Dim res As String
    Dim url As String = "https://api.dingtalk.com/v1.0/calendar/users/1B2EFZ1oZ12mGfeaTnm7CAiEiE12/calendars/primary/events"
    Dim hc As New HttpClient(url)
    hc.SkipError = True
    hc.Headers.Add("x-acs-dingtalk-access-token", "e6b4f753db3a373d82e6ecf30e21232")
    Dim jo As New JObject
    Dim jo1 As New JObject
    jo("summary") = "测试日程创建"
    jo1("dateTime") = "2022-05-26T10:45:30+08:00"
    jo1("timeZone") = "Asia/Shanghai"
    jo("start") = jo1
    jo1 = JObject.Parse("{}")
    jo1("dateTime") = "2022-05-26T11:45:30+08:00"
    jo1("timeZone") = "Asia/Shanghai"
    jo("end") = jo1
    jo("isAllDay") = False
    
    Output.Show(jo.ToString)
    hc.Content = jo.ToString
    res = hc.GetData()
    Output.Show(res)
   OutPut.Show("更新日期:" & hc.LastModified)
   OutPut.Show("状态码:" & hc.StatusCode)
   OutPut.Show("状态描述:" & hc.StatusDescription)
   OutPut.Show("内容类型:" & hc.ResponseContentType)
   OutPut.Show("内容长度:" & hc.ResponseContentLength)
   For Each key As String In hc.ResponseHeaders.Keys \'显示服务器返回的头部信息
       OutPut.Show(Key & ":" & hc.ResponseHeaders(key))
   Next
通过这个新版的API创建日程,如果这个红色部分的组织者的unionId错误的话(包括请求参数格式错误等),
错误情况下获取的内容是这样的:

更新日期:00:00:00
状态码:400
状态描述:Bad Request
内容类型:
内容长度:0


和实际钉钉返回的信息差别比较大,请教是如何接收这个错误信息呢?
钉钉创建日程文档链接https://open.dingtalk.com/document/orgapp-server/create-event


通过钉钉提供的API测试返回如下:
图片点击可在新窗口打开查看
[此贴子已经被作者于2022/5/26 13:49:42编辑过]