【问题标题】:'Bad Request 400' response when getting outlook ics url获取 outlook ics url 时出现“错误请求 400”响应
【发布时间】:2023-02-14 18:58:00
【问题描述】:

我一直在获取 ical 提要的遗留项目中遇到问题。

尝试通过任何 outlook.office365 url 获取日历时,我收到“错误请求 400”的响应。

我已经使用 PostMan 和在线 ics 验证器测试了所有 url,所以我知道这与日历本身不可用无关。

我正在使用 npm 包“request”来获取日历,它可以使用任何不是来自 outlook.office365.com 主机的 url。

出于隐私原因,我无法分享任何使用的网址。

这是发送请求的地方。

async.waterfall([
        cb => {
          request.get(url, {}, function (err, r, data) {
            console.log('response', r.statusCode); // this will be 400 for any outlook.office365 ics url but not for others.
            if (err) return cb(err, null);
            try {
              ...
            } catch (err) {
              ...
            }

是否需要附加任何标题才能接收 outlook.office365 日历?我在网上找不到任何关于要求的信息

【问题讨论】:

    标签: javascript node.js outlook request office365


    【解决方案1】:

    我遇到过同样的问题。 我比较了 Postman 中的请求标头,并尝试在我的应用程序中模仿它们。 添加 Postman User Agent 字符串使它对我有用:

            HttpClient myHttpClient = new HttpClient();
    
            myHttpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("*/*"));
            myHttpClient.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue("PostmanRuntime","7.30.1"));
    
            var response = myHttpClient.GetAsync(calendarUrl).Result;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-08-06
      • 1970-01-01
      • 2016-12-08
      • 1970-01-01
      • 2014-08-19
      • 2021-04-21
      相关资源
      最近更新 更多