【问题标题】:vba run time error '- 2146697208 800c0008 )': the download of the specified resource has failed telegramvba运行时错误'- 2146697208 800c0008)':指定资源的下载失败电报
【发布时间】:2020-05-23 16:11:15
【问题描述】:

请求您帮助解决以下问题,我被打击了两天,

vba 运行时错误'- 2146697208 (800c0008 )': 指定资源下载失败

这是我的代码供您参考:

Sub telebot15status155555()

   'Program Excel Messeger
   ' Purpose : Send Message to Telegram
   ' Author : John Eswin Nizar
   ' Date : 09 October 2017

    Dim objRequest As Object
    Dim strChatId As String
    Dim strMessage1 As String
    Dim strMessage2 As String
    Dim strPostData As String
    Dim strResponse As String

    strChatId = "@messstatus"
    strMessage1 = ""
    strMessage2 = Now()

    'strMessage = "hallo"

     strPostData = "chat_id=" & strChatId & "&text=" & strMessage1 & strMessage2

     Set objRequest = CreateObject("MSXML2.XMLHTTP")

     With objRequest
         .Open "POST", "https://api.telegram.org/sendMessage?", False
         .setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
         .send (strPostData)
         GetSessionId = .responseText
         MsgBox GetSessionId
     End With
End Sub

【问题讨论】:

    标签: excel vba


    【解决方案1】:

    我的建议是在打开 DevTools 的情况下在 Chrome 中执行此 API 调用。或者访问发生这种情况的页面,然后在“网络”选项卡上找到请求。然后看看标题。

    debug.print strPostData 正在返回:

    chat_id=@messstatus&text=2/7/2020 9:40:23 AM
    

    对于表单 urlencoded 的 API,该格式看起来不正确。您需要在 DevTools 中查看网站实际发送和接收的内容才能复制它。

    IOW,由于 API 格式不正确,找不到资源。从基本 api 来看,它实际上也是一个 QueryString,因为它以 ? 结尾。这可能意味着您必须将 POST 数据的 url-encode 格式转换为主要 HTTP 请求的 QueryString。看看这里:Pass Parameters in VBA HTTP Post Request

    【讨论】:

    • 感谢您的回复,相同的代码在 windows 7 64 位中运行,但在 windows 32 位中出现错误
    • 感谢您的回复,相同的代码在 windows 7 64 位 m/C 中运行,但在 windows 32 位 m/C 中出现错误
    猜你喜欢
    • 1970-01-01
    • 2010-11-27
    • 1970-01-01
    • 1970-01-01
    • 2020-03-15
    • 1970-01-01
    • 1970-01-01
    • 2023-03-24
    • 1970-01-01
    相关资源
    最近更新 更多