我正在 grails 中编写代码,该代码正在使用 httpbuilder 进行后期调用。如果我对 body 的值进行硬编码,一切正常,但是当我使用变量传递相同的值时,它会一直给我 -
Unprocessable Entity. Stacktrace follows:
Message: Unprocessable Entity
Line | Method
->> 636 | defaultFailureHandler in groovyx.net.http.HTTPBuilder
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 492 | doRequest in ''
| 427 | doRequest . . . . . . in ''
| 376 | request in ''
代码如下 -
def input = "s3://in_folder/inputFile.mp3"
def outFile = "outFile.m3u8"
def http = new HTTPBuilder("https://app.gridserver.com")
http.request( groovyx.net.http.Method.POST, groovyx.net.http.ContentType.JSON ) { req ->
uri.path = 'api/v2'
headers.Accept = 'application/json'
headers.'Key' = "ssdflkjdf8338fdjsd"
body = ["input": input,
"output":[ "filename": outFile,
"format": "mp3",
] ]
response.success = { resp, reader ->
println "Got response: ${resp}"
}
}
}
如果我在这里用实际值替换变量“输入和输出文件”,那么它工作正常。