Forum Discussion
renatoathaydes
12 years agoContributor
Hi there,
Could you please try to use httpclient version 4.2.1 at least.
Grapes (used to Grab this dependency) is having some kind of problem with 4.1.1!
It worked for me with 4.2.1..... please notice that the latest version of this library in Maven Central is already 4.2.5.
Unfortunately, LoadUI's ScriptRunner error messages are really unhelpful... please try to run your script with the Groovy Console before trying it in LoadUI so you get a better error message
By the way, here is a more Groovy version of your script, hope this helps:
Could you please try to use httpclient version 4.2.1 at least.
Grapes (used to Grab this dependency) is having some kind of problem with 4.1.1!
It worked for me with 4.2.1..... please notice that the latest version of this library in Maven Central is already 4.2.5.
Unfortunately, LoadUI's ScriptRunner error messages are really unhelpful... please try to run your script with the Groovy Console before trying it in LoadUI so you get a better error message

By the way, here is a more Groovy version of your script, hope this helps:
@Grab(group='org.apache.httpcomponents', module='httpclient', version='4.2.1')
import org.apache.http.client.methods.HttpPost
import org.apache.http.message.BasicNameValuePair
import org.apache.http.impl.client.DefaultHttpClient
import org.apache.http.client.entity.UrlEncodedFormEntity
import org.apache.http.protocol.HTTP
def post = new HttpPost("http://search.yahoo.com/search")
def parameters = [ new BasicNameValuePair("p", "loadui") ]
def sendentity = new UrlEncodedFormEntity(parameters, HTTP.UTF_8)
post.entity = sendentity
def client = new DefaultHttpClient()
response = client.execute post
return ["responseBody": response.entity.content.text]