【发布时间】:2018-06-26 02:10:21
【问题描述】:
我目前正在使用这个link 在 Python 中编写一个程序,该程序将使用 Datadog API 为 POST、PUT 和 DELETE 请求发送 curl 命令。到目前为止,该请求似乎正在按我的意愿触发,但它不会占用我的凭据。我不完全确定服务挂钩网址是什么,但我相信它可能是罪魁祸首。谁能告诉我如何为此找到以下 Slack 特定元素?
- 帐户(这是您的 Slack 名称还是您的 Slack 句柄?假设我的 Slack 名称是“John Doe”,但我的句柄是“J.D.”)
- Slack 服务挂钩 URL(不知道这是什么或在哪里可以找到)
这是我在 Python 中的测试脚本:
os.system("curl -v -X POST -H \"Content-type: application/json\" \
-d '{\
\"service_hooks\": [\
{\
\"account\": \"[???]\",\
\"url\": \"[???]\"\
}\
],\
\"channels\": [\
{\
\"channel_name\": \"[#???]\",\
\"transfer_all_user_comments\": \"false\",\
\"account\": \"[???]\"\
}\
]\
}' \
\"https://api.datadoghq.com/api/v1/integration/slack?api_key=$"+[???]+"&application_key=$"+[???]+"\"");
结果是:
M-C02TW43FHV2Q:python foobar$ python main.py
Note: Unnecessary use of -X or --request, POST is already inferred.
* Trying 00.000.000.00...
* TCP_NODELAY set
* Connected to api.datadoghq.com (00.000.000.00) port 000 (#0)
* TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_000_GCM_SH00000
* Server certificate: *.datadoghq.com
* Server certificate: COMODO RSA Domain Validation Secure Server CA
* Server certificate: COMODO RSA Certification Authority
> POST /api/v1/integration/slack?api_key=00000000000000000000000000000&application_key=00000000000000000000000000000000 HTTP/1.1
> Host: api.datadoghq.com
> User-Agent: curl/0.00.0
> Accept: */*
> Content-type: application/json
> Content-Length: 292
>
* upload completely sent off: 292 out of 292 bytes
< HTTP/1.1 403 Forbidden
< Date: Tue, 26 Jun 2018 01:42:25 GMT
< Content-Type: application/json
< Content-Length: 31
< Connection: keep-alive
< Vary: Accept-Encoding
< Pragma: no-cache
< Cache-Control: no-cache
< X-DD-VERSION: 00.000000
< DD-POOL: dogweb_sameorig
< X-Frame-Options: SAMEORIGIN
< X-Content-Type-Options: nosniff
< Strict-Transport-Security: max-age=100000000;
<
* Connection #0 to host api.datadoghq.com left intact
{"errors": ["Invalid API key"]}M-000000000000:python foobar$
如果能帮助我查找此信息,我将不胜感激!
【问题讨论】:
标签: python curl slack slack-api datadog