访问doPost()中的请求标头 [英] Access request headers in doPost()

查看:156
本文介绍了访问doPost()中的请求标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要验证Webhook,我需要从请求标头中获取参数.到目前为止,如果实际上可以在Apps脚本中访问这些标头,则我找不到任何信息.到目前为止,唯一有效的方法是访问发布请求的正文.

To verify a webhook i need to get a parameter from the request headers. So far i couldn't find any information if it is actually possible to access these headers within Apps Scripts. Only thing that works so far is accessing the body of the post request.

function doPost(e) {
    // something like this
    var headerParam = e.headers['Content-Type'];
    // ...
}

推荐答案

不幸的是,当前无法使用doPost()触发器来实现.但是,Google的问题跟踪器上有针对此问题的待处理功能请求.如果您希望看到此功能受支持,请在以下链接的问题主题上发表评论,并确保在以下链接中对该问题进行加星:

Unfortunately this is not currently possible with doPost() triggers. However there is a pending feature request for this issue on Google's issue tracker. If you'd like to see this feature supported please leave a comment (on the issue thread linked below) and be sure to STAR the issue at the following link:

https://issuetracker.google.com/issues/67764685

我当前使用的解决方法是利用Google Cloud Functions.我在这里.

The workaround I currently use is to leverage Google Cloud Functions. I wrote a related article about it here.

这篇关于访问doPost()中的请求标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆