0
我在groovy脚本中发送curl请求时遇到困难,并且正在查看是否有人可以指引我朝着正确的方向。在groovy脚本中发送curl请求
我不断收到无效负载和通配错误。如果我做了我的终端内以下正常工作
curl -X POST -H 'Content-type: application/json' --data '{"attachments": [{"color": "#2A9B3A", "author_name": "Richard Lewis", "title": "MY Build Status", "title_link": "http://example.co.uk", "text": "Successful Build" }]}' https://hooks.slack.com/services/webhook
但是当我尝试和我的Groovy脚本内做到这一点失败
sh """#!/bin/bash -l
curl -X POST -H 'Content-type: application/json' --data {"attachments": [{"color": "#2A9B3A", "author_name": "Richard Lewis", "title": "My Build Status", "title_link": "http://example.co.uk", "text": "Successful Build" }]} "https://hooks.slack.com/services/T122JHEUW/webhook"
"""
我将如何正确格式化这个还是有更好的办法发送此请求?这将是清洁的,如果我能省则--data
的变量传递到我的请求,我知道,但我有问题,这也是(有效载荷错误),我想下再次
格式化任何帮助表示赞赏
谢谢
替代最简单的方法 - https://github.com/jwagenleitner/groovy-wslite – Rao
我只是碰到那个......谢谢,试着我们说话:-) – Richlewis