Let's say I have a REST service that allows you to search for rail journeys - and that once you have selected them, you can book them.
The endpoint is example.com/service/v1/book
, and to create the booking, you use a POST
.
Because in reality, when you get to the booking state, the request would require a lot of data, the details of the booking are send as JSON.
For simplicity's sake, let's assume the body just takes the journey legs at the moment:
{
"journey" : {
"type" : "return",
"outgoing" : {
"from" : "LON",
"to" : "NCL"
},
"return" : {
"from" : "NCL",
"to" : "LON"
}
}
}
Now, for a one-way ticket, that bit would obviously look slightly different, yet the resource (or HTTP method) wouldn't change - it would still be POST example.com/service/v1/book
:
{
"journey" : {
"type" : "single",
"outgoing" : {
"from" : "LON",
"to" : "NCL"
}
}
}
The service would have to deal with it slightly differently, though. So, we'd want to test both.
How would you structure that in SoapUI?
I thought you'd create the resource (with the POST method), then create two different test cases, "one-way" and "return".
What I'm not sure of is how I'd then be able to pass the different payloads in? And where they'd be defined...?