首页 > 解决方案 > 通过 VBA 上传文件时收到 405 错误

问题描述

我正在尝试通过 VBA 将文件从 Outlook 上传到我的 REST API。

我越来越

405 不允许

VBA 代码

Sub uploadjustfile()
    Set objhttp = CreateObject("MSXML2.ServerXMLHTTP")
    URL = "https://test-url.com/api/upload"
    objhttp.Open "POST", URL, False
    objhttp.setRequestHeader "Content-type", "application/json"
    objhttp.setOption 2, 13056
    objhttp.Send ("file=@D:/Zip/one.txt")
    MsgBox objhttp.responsetext
End Sub

REST API 代码

$_FILES = json_decode(file_get_contents('php://input'),true);
$response = array('status'=>1);
$this->response($response,200);

此 API 代码在 PHP 脚本中工作。使用测试表单,输出符合预期。

我使用 CodeIgniter 作为后端 PHP 框架。

标签: phpvbarestcodeigniteroutlook

解决方案


推荐阅读