0

在解析从 GitHub WebHook 收到的有效负载时,遇到此问题 JSONDecodeError: Expecting value: line 1 column 1 (char 0)

有效载荷看起来像

payload=%7B%22action%22%3A%22created%22%2C%22issue%22%3A%7B%22url%22%3A%22https%3A%2F%2Fapi.github.com%2Frepos%2FChaiBapchya%2Fincubator-mxnet%2Fissues%2F13%22%2C%22repository_url%22%3A%22https%3A%2F%2Fapi.github.com%2Frepos%2FChaiBapchya%2Fincubator-mxnet%22%2C%22labels_url%22%3A%22https%3A%2F%2Fapi.github.com%2Frepos%2FChaiBapchya%2Fincubator-mxnet%2Fissues%2F13%2Flabels%7B%2Fname%7D%22%2C%22comments_url%22%3A%22https%3A%2F%2Fapi.github.com%2Frepos%2FChaiBapchya%2Fincubator-mxnet%2Fissues%2F13%2Fcomments%22%2C%22events_url%22%3A%22https%3A%2F%2Fapi.github.com%2Frepos%2FChaiBapchya%2Fincubator-mxnet%2Fissues%2F13%2Fevents%22%2C%22html_url%22%3A%22https%3A%2F%2Fgithub.com%2FChaiBapchya%2Fincubator-mxnet%2Fpull%2F13%22%2C%22id%22%3A57165580

错误堆栈跟踪

File "/var/lang/lib/python3.7/json/__init__.py", line 348, in loads
    return _default_decoder.decode(s)
  File "/var/lang/lib/python3.7/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/var/lang/lib/python3.7/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

4

1 回答 1

0

仔细查看 GitHub WebHook 配置和有效负载输出后,发现不匹配。

GitHub WebHook 被配置为在content type : x-www-form-urlencoded. 此外,有效载荷打印看起来也像 urlencoded 而不是 json。

但是我在 AWS Lambda 中解析 webhook 的辅助函数需要一个 json。

更改 webhook 有效 更新了 GitHub WebHook

于 2020-02-29T03:08:18.310 回答