【问题标题】:How to call rest API using ScriptRunner rest Endpoint in jira如何在jira中使用ScriptRunner rest Endpoint调用rest API
【发布时间】:2020-02-12 06:19:30
【问题描述】:

我想使用 Scriptrunner 端点调用 REST API。

下面的网址有参数PlantPartNumber

https://exex.example.com/API/Engineering/Analysis/Validate?Plant=EAES&PartNumber=R170025Y001001

当我从 REST 端点调用 URL 时,我想在其他应用程序中更新 PlantPartNumber 的状态。我该怎么做?

  • 当我运行 REST 端点时,我想要下面圈出的输出

【问题讨论】:

    标签: jira-rest-api


    【解决方案1】:

    你可以试试下面的脚本,(根据你的值和方法类型修改)

        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}"
            }
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-25
      • 1970-01-01
      • 2016-02-17
      • 1970-01-01
      • 1970-01-01
      • 2012-08-05
      相关资源
      最近更新 更多