Forum Discussion
M_McDonald
16 years agoSuper Contributor
You can create a MockService and put code like the following in the OnRequest script:
def json = """{
"firstName": "John",
"lastName": "Smith",
"age": 25,
"address": {
"streetAddress": "21 2nd Street",
"city": "New York",
"state": "NY",
"postalCode": "10021"
},
"phoneNumber": [
{ "type": "home", "number": "212 555-1234" },
{ "type": "fax", "number": "646 555-4567" }
]
}
"""
def response = mockRequest.getHttpResponse()
response.setContentType("application/json")
def writer = response.getWriter();
writer.write(json)
writer.close()