无法在线订阅 SharePoint 的网络钩子

时间:2021-05-17 07:43:22

标签: java sharepoint webhooks sharepoint-online

我们无法从我们的 Spring-Boot 应用程序在线订阅 SharePoint 的网络钩子。

提供有效的通知 URL(启用 https、可公开访问、有效域名、Post 方法)作为参数,同时使用 rest API 以订阅 web-hook。

    @PostMapping(value = "/spnotification")
    @ResponseBody
    public ResponseEntity<String> handleSPValidation(@RequestParam final String validationtoken) {
        LOG.info("validationToken : " + validationtoken);
        return ResponseEntity.ok().contentType(MediaType.TEXT_PLAIN)
                .body(validationtoken);
    }

并且在此通知 URL 端点上,我们能够从共享点接收验证字符串作为参数和我们将在不到 5 秒内退出的相同字符串,内容类型为 text/plain 和 http 状态代码 200 作为响应.

仍然收到带有以下错误消息的 400 个错误请求。

400 Bad Request: [{"error":{"code":"-1, System.InvalidOperationException","message":{"lang":"en-US","value":"Failed to validate the notification URL 'https://example.com/notification-listener-service/api/webhook/spnotification'."}}}]

注意:我们正在关注此 API documentation 以订阅网络钩子。

我们也出于同样的目的尝试了 Graph API,但在这种情况下会出现以下错误。

"error": {
        "code": "InvalidRequest",
        "message": "The server committed a protocol violation. Section=ResponseHeader Detail=CR must be followed by LF"
       
    }

请查找此图表以进一步了解此问题。

enter image description here

如果有人能帮助我们,我们真的很感激。

1 个答案:

答案 0 :(得分:0)

请检查@PostMapping(value = "/notification", headers = { "content-type=text/plain" }) enter image description here

@PostMapping(value = "/notification", headers = { "content-type=text/plain" }) 
@ResponseBody
    public ResponseEntity<String> handleSPValidation(@RequestParam final String validationtoken) {
        LOG.info("validationToken : " + validationtoken);
        return ResponseEntity.ok().contentType(MediaType.TEXT_PLAIN)
                .body(validationtoken);
    }

GitHub Code