HTTP POST 正文在 VBA 中的请求 (MSXML2.ServerXMLHTTP)
HTTP POST Request with body in VBA (MSXML2.ServerXMLHTTP)
我正在尝试发送带有 JSON 正文的 POST 请求,但我不断收到“不支持内容类型 'text/calendar;charset=UTF-8'”的错误消息。我尝试使用 text/plain 并将后端服务更改为 text/plain 但我一直收到相同的 Content-type ... not supported 错误。
我的后端服务正在返回 .ics (icalendar) 格式的文本,我想将其加载到 Outlook 日历中。
这是我在客户端尝试的内容(Outlook 宏 VBA)
Set httpCall = CreateObject("MSXML2.ServerXMLHTTP")
URL = apiURL & apiPort & "/icalendar/unavailabilities"
httpCall.Open "POST", URL, False
httpCall.setRequestHeader "Content-Type", "text/calendar;charset=UTF-8"
httpCall.Send "{""requestedComponentTypeIdAndCount"": ""33"":""2""},""requestedStartTime"":""2021-05-20T08:00:00.000-05:00"",""requestedEndTime"":""2021-05-22T16:00:00.000-05:00""}"
MsgBox (httpCall.responseText)
我使用相同端点的 POST 请求示例
请求 content-type 应该是 application/json
text/calendar
是 响应 content-type,通常会作为“接受”header:
我正在尝试发送带有 JSON 正文的 POST 请求,但我不断收到“不支持内容类型 'text/calendar;charset=UTF-8'”的错误消息。我尝试使用 text/plain 并将后端服务更改为 text/plain 但我一直收到相同的 Content-type ... not supported 错误。
我的后端服务正在返回 .ics (icalendar) 格式的文本,我想将其加载到 Outlook 日历中。
这是我在客户端尝试的内容(Outlook 宏 VBA)
Set httpCall = CreateObject("MSXML2.ServerXMLHTTP")
URL = apiURL & apiPort & "/icalendar/unavailabilities"
httpCall.Open "POST", URL, False
httpCall.setRequestHeader "Content-Type", "text/calendar;charset=UTF-8"
httpCall.Send "{""requestedComponentTypeIdAndCount"": ""33"":""2""},""requestedStartTime"":""2021-05-20T08:00:00.000-05:00"",""requestedEndTime"":""2021-05-22T16:00:00.000-05:00""}"
MsgBox (httpCall.responseText)
我使用相同端点的 POST 请求示例
请求 content-type 应该是 application/json
text/calendar
是 响应 content-type,通常会作为“接受”header: