Forum Discussion

srishtiK's avatar
srishtiK
Occasional Contributor
9 years ago

set MultipartEntity as POST body in rest service

I have added a groovy step before my REST Service Step. The groovy Script step creates a MultipartEntity  which needs to be set as the POST request body of the REST service. How to do this. I have tried

  •  testRunner.testCase.testSteps["Step1"].setPropertyValue( "Request",multiPartContent )
  • testRunner.testCase.testSteps["Step1"].httpRequest.entity=multiPartContent

But of course both the methods are wrong. Most examples online are like:

HttpClient httpclient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(someURL);

httpPost.setEntity(multiPartContent );

HttpResponse response = httpclient.execute(httpPost);

 

I do not want to create a new client from groovy.Just past the multiPartContent to the entity of an existing test step.