cancel
Showing results for 
Search instead for 
Did you mean: 

Pass JSON in PUT Request - SOAPUI Pro for REST service

SOLVED
New Contributor

Pass JSON in PUT Request - SOAPUI Pro for REST service

I am creating mock stubs using SoapUI to test our application code. One scenario is for the mock stubs to accept PUT request and read the JSON request coming through. I don't know how to pass JSON through a PUT request in SOAP UI.

Ram
4 REPLIES
Community Leader

Re: PUT Request in SOAPUI Pro for REST service

Hi ramprakash4,

You were asking about this thread originally, but I don't understand the original question, so could you edit your post above to ask it again in your own words?

Are you just trying to make a simple REST request using PUT method that has JSON in the body?

Or is there some either meaning when he says "Content/schema"?

New Contributor

Re: PUT Request in SOAPUI Pro for REST service

Thanks mate. Updated description
Highlighted
Community Leader

Re: PUT Request in SOAPUI Pro for REST service

 Oh, okay, I see what this is about... I didn't get that at all from the other question!

 

This is a known bug actually. SoapUI doesn't seem to be able to get the body on PUT/DELETE messages. The same bug also makes it so that you can't see the body in the "raw" view of the sent request.

 

You can fix for your MockServices by adding some code to the OnRequest script. I took inspiration from here.

 

mockRequest.with { if (method.toString() == 'PUT' || method.toString() == 'DELETE') {
    BufferedReader br = new BufferedReader(new InputStreamReader(request.getInputStream(), "UTF-8"));
    StringBuilder sb = new StringBuilder()
    while((s=br.readLine())!=null) { sb.append(s) }
    requestContent = sb.toString()
}}

Example project is attached.

New Contributor

Re: PUT Request in SOAPUI Pro for REST service

This is brilliant. Worked like a charm. Thanks a lot. You saved me from wasting many hours. 

API Summer News

Congratulate last week's winners here:
1. @sanj - $50
2. @Sehuang and @aaronpliu - $35
3. @jhanzeb1 - $15

To do this week:
- Ask product-related questions
- Reply to any questions

Win $50, $35 or $15 gift card!
Winners will be decided next Monday (Aug 27)

Top Kudoed Authors
Are You In?