Jenkins pipeline 如何通过http请求在http get方法中发送JSON编码的http正文

Jenkins pipeline 如何通过http请求在http get方法中发送JSON编码的http正文,jenkins-pipeline,httprequest,Jenkins Pipeline,Httprequest,基本上,我正在使用jenkins管道发送http请求 在中,可以在http get方法中发送JSON编码的http正文。但是,当运行下面的jenkins管道脚本时,服务器端的http正文是空的。使用http get方法时是否允许在http正文中发送JSON数据 import groovy.json.JsonOutput def reqBody = [ 'key01': 'val01', 'key02': 'val02', ] def resp = httpRequest( url:

基本上,我正在使用jenkins管道发送http请求

在中,可以在http get方法中发送JSON编码的http正文。但是,当运行下面的jenkins管道脚本时,服务器端的http正文是空的。使用http get方法时是否允许在http正文中发送JSON数据

import groovy.json.JsonOutput

def reqBody = [
  'key01': 'val01',
  'key02': 'val02',
]
def resp = httpRequest(
  url: '127.0.0.1:8000/api/service01',
  httpMode: 'GET',
  contentType: 'APPLICATION_JSON',
  requestBody: JsonOutput.toJson(reqBody),
)

一种可能的解决方案是在服务器端重构脚本,以读取HTTPPOST中的参数。在此之后,http主体拥有json数据

import groovy.json.JsonOutput

def reqBody = [
  'key01': 'val01',
  'key02': 'val02',
]
def resp = httpRequest(
  url: '127.0.0.1:8000/api/service01',
  httpMode: 'POST',
  contentType: 'APPLICATION_JSON',
  requestBody: JsonOutput.toJson(reqBody),
)