Contributions
Re: use get as a template for post in RESTful server
Rupert, Just to comment on your comment.J I wanted to combine the slurp and the JSONPath walk into one step. Ultimately this will be an assertion so if walking the path fails then the Grovvy Script will fail and the assertion will fail, thus failing the test case. Your solution is simpler but removes the JSONPath walk. Brian2.6KViews0likes1CommentRe: use get as a template for post in RESTful server
Rupert, Earlier this week I hacked the answer I needed. It turned out to be as simple as I expected. import groovy.json.JsonOutput import com.jayway.jsonpath.JsonPath def response = context.expand('${GetRecord#Response}') def responseJson = JsonPath.read(response, "result[0]") // change the name of the record responseJson.name = "abc123" // put the modified response into the the Update step as the Request text def jsonString = JsonOutput.toJson(responseJson) testRunner.testCase.testSteps["UpdateRecord"].setPropertyValue("Request", jsonString) What was critical for me was that I did not have to know about any of the other fields, all I had to do was change the name. So now there are 3 test steps: GetRecord Groovy script UpdateRecord Thanks again for your help.2.7KViews2likes3CommentsRe: use get as a template for post in RESTful server
Rupert, Thanks for your reply, it got me a little farther. I'm still baffled why this idea of GET record, Modify record, PUT record is not more common; this makes me think I'm doing something wrong. I took a look at your book reference and that helped me understand the slurper a little better. I’m ready to purchase a book on SOAPUI if I believe it has enough information on the Free version. I see many references to the NG/ ReadyAPI version which makes me shy away some books. This is what I have so far: def responseJson = context.expand('${Response 1#Response}') def slurper = new JsonSlurper().parseText(responseJson) slurper.name == 'BBE123' def requestJson = context.blah('$Response 2#Request}') requestJson.blat = slurper I can’t answer your toString() comment until I figure out the ‘blah’ and 'blat' methods above. As you can see I'm new to objects and what goes where. Thanks again for your help.2.7KViews0likes5Commentsuse get as a template for post in RESTful server
Hello all, I'm new to SOUPUI, and I'm using the free version of SOUPUI. I’m trying to write some test cases. I spent all morning looking for this and I can't believe this has never been asked. I'm sure I'm using the wrong nomenclature to ask this and so my search is failing. What I want to do is: make a GET request [{ "id": "123", "name": “abc”, "encrypted": false, “happy”: true }] Modify one or two items in the JSON response [{ "id": "123", "name": “ghi”, "encrypted": true, “happy”: true }] Send the JSON response to my server as a POST – thus modifying the record (123) on the server If someone could point me to a simple example that would be great. I see lots of examples on how to do a property transfer and such but nothing on reusing a response. I might have to use Groovy to do this but it seems like SOAPUI can do it already. Thanks in advanceSolved2.8KViews0likes7Comments