У меня возникли проблемы с передачей параметров json веб-действию. Я знаю, что веб-действие работает на указанном URL http://projects.example.net/example/bugnetwebservice.asmx/MobileBuildAction
, как я тестировал с почтальоном с параметрами JSon:Groovy HttpBuilder json input problem
{
featureIdStr: 31,
actionStr: 1,
comment: "Hello world"
}
и получите ответ:
{
"d": "Succeeded"
}
Всякий раз, когда я пытаюсь запустить его в заводной, однако, я получаю такой ответ:
Jun 10, 2016 9:54:25 AM net.sf.json.JSONObject _fromBean
INFO: Property 'value' of class org.codehaus.groovy.runtime.GStringImpl has no read method. SKIPPED
Failure: 500
Вот мой код:
@Grab(group='org.codehaus.groovy.modules.http-builder', module='http-builder', version='0.7.1')
import groovyx.net.http.*
import static groovyx.net.http.ContentType.*
import static groovyx.net.http.Method.*
def http = new HTTPBuilder("http://projects.example.net/")
def issueId = 31
def msg = "Build Failed"
def jsonBody = [:]
jsonBody.put("featureIdStr", issueId)
jsonBody.put("actionStr", 0)
jsonBody.put("comment", "${msg}: <a href='http://www.google.com'}'>Googles Job</a>")
http.request(POST, JSON) {
uri.path = "/example/bugnetwebservice.asmx/MobileBuildAction"
body = jsonBody
response.success = { resp ->
println "Success! ${resp.status}"
}
response.failure = { resp ->
println "Failure: ${resp.status}"
}
}
Пожалуйста, помогите!
Вы можете попытаться изменить последний 'put' значение' "$ {сбщ}: Googles Job" .ToString() '? Я думаю, что я столкнулся с аналогичными проблемами, связанными с обработкой String и GString в HTTPBuilder. – bdkosher