jira-rest-api - 如何在jira中使用ScriptRunner rest Endpoint调用rest API
问题描述
我想使用 Scriptrunner 端点调用 REST API。
下面的 URL 包含参数Plant
和PartNumber
。
https://exex.example.com/API/Engineering/Analysis/Validate?Plant=EAES&PartNumber=R170025Y001001
Plant
当我从 REST 端点调用 URL 时,我想更新PartNumber
其他应用程序的状态。我怎样才能做到这一点?
解决方案
您可以尝试使用以下脚本,(根据您的值和方法类型进行修改)
import groovyx.net.http.HTTPBuilder
import static groovyx.net.http.ContentType.*
import groovyx.net.http.ContentType
import static groovyx.net.http.Method.*
import groovy.json.JsonSlurper
import net.sf.json.groovy.JsonSlurper
def http = new HTTPBuilder('https://YOUR REST URL')
http.request(POST) {
requestContentType = ContentType.JSON
body = [username: 'USERNAME', password: 'PASSWORD']
response.success = { resp, JSON ->
return JSON
}
response.failure = { resp ->
return "Request failed with status ${resp.status}"
}
}
推荐阅读
- tensorflow - 未能加载本机 tensorflow 运行时
- android - 如何在垂直视图中显示选项卡布局?
- c++ - 重建还是清理并建造?
- flutter - 如何停止 Flutter 的 VSCode AutoComplete 参数?
- javascript - 单击输入的文本时如何使用 onClick 清除 EditText?
- sql - 如何在 SQL 中选择顶行
- apache-spark - 如何在不访问 spark 历史 UI 的情况下了解 spark 执行时间?
- ios - 参数中的函数是否在闭包中被捕获?
- c# - 类类型约束必须在任何其他约束之前
- php - Symfony 3.4:试图调用一个名为的未定义方法