我正在使用httpbuilder编写一个使用grails进行调用的代码。一切正常,如果我硬编码身体的值,但当我使用变量传递相同,然后它继续给我 -
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}"
}
}
}
如果我将变量“input and outFile”替换为实际值,那么它可以正常工作。
答案 0 :(得分:0)