Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Groovy脚本中使用HTTP Builder将JSON参数发布到REST HTTPS URL_Json_Rest_Jenkins_Groovy_Servicenow - Fatal编程技术网

在Groovy脚本中使用HTTP Builder将JSON参数发布到REST HTTPS URL

在Groovy脚本中使用HTTP Builder将JSON参数发布到REST HTTPS URL,json,rest,jenkins,groovy,servicenow,Json,Rest,Jenkins,Groovy,Servicenow,我正在使用Groovy脚本在Jenkins作业中使用HTTP Builder将JSON参数发布到REST HTTPS URL。 以下是我的脚本:- import groovyx.net.http.HTTPBuilder import static groovyx.net.http.ContentType.URLENC def http = new HTTPBuilder( 'http://restservice.appshop.com/' ) def postBody = [name: 'bo

我正在使用Groovy脚本在Jenkins作业中使用HTTP Builder将JSON参数发布到REST HTTPS URL。
以下是我的脚本:-

import groovyx.net.http.HTTPBuilder
import static groovyx.net.http.ContentType.URLENC

def http = new HTTPBuilder( 'http://restservice.appshop.com/' )
def postBody = [name: 'bob', title: 'customer'] // will be url-encoded

http.post( path: '/', body: postBody,
           requestContentType: URLENC ) { resp ->

  println "POST Success: ${resp.statusLine}"
  assert resp.statusLine.statusCode == 201
}
我得到以下错误:-

无法解析groovyx.net.http.httpbuilder类

我也尝试过使用@Grab,但仍然只有错误


请帮助我使用此HTTP Builder。

请更新您的代码片段,以包含您正在尝试的@Grab@Grab(group='org.codehaus.groovy.modules.HTTP Builder',module='HTTP-Builder',version='0.7')servicenow从何而来?嗨,Joey,我想使用Jenkins创建一个服务更改。有什么可能的方法吗?请更新您的代码片段,以包含您正在尝试的@Grab。@Grab(group='org.codehaus.groovy.modules.http builder',module='http-builder',version='0.7')servicenow的作用在哪里?嗨,Joey,我想用Jenkins在service now中创建一个更改。有什么可能的办法吗?