Http Status Codes
SOLVED- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Http Status Codes
Hi
is there a way of adding additional http status codes to the pre defined list for virt responses?
creating a virt but need a status code of 428 - Precondition Required but that isnt in the drop down list
failing the ability to configure that list is it possible to set the status on the fly? and if so how would I do that?
thanks
Mike
Solved! Go to Solution.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
You can set any HTTP status code for a particular response.
You can do it by selecting the response then clicking the Script on the right inspector and then pasting this code
mockResponse.responseHttpStatus = 428
Hope this helps!
Regards,
Shadid
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi
that works to an extent
I get the following response
-------------
HTTP/1.1 428 428
Content-Type: application/json
Content-Encoding: gzip
Content-Length: 60
Server: Jetty(6.1.26)
{
"reason" : "Precondition required"
}
-------------
If I dont use that line in the response script and just select a response code from the drop down list I get something like this
-------------
HTTP/1.1 401 Unauthorized
Content-Type: application/json
Content-Encoding: gzip
Content-Length: 60
Server: Jetty(6.1.26)
{
"reason" : "Precondition required"
}
-------------
How do I change the text associated with the code?
i.e. change '428 428' to '428 Precondition Required'
for ref I'd already tried this which didnt work
mockResponse.setResponseHttpStatus = 428
(referenced from - http://www.soapui.org/apidocs/com/eviware/soapui/model/mock/MockResponse.html#setResponseHttpStatus(...
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi again,
Right now, this is not possible. It is the underlying HttpServletResponse which sets the reason phrase from the status code, and 428 is not there so it does not find any mapping reason phrase.
By the way, as a workaround you can send a custom header in the response with the reason phrase (Precondition Required), if that helps.
Regards,
Shadid
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks
I'll use the workaround for now, any idea if the 'HttpServletResponse ' is going to be updated to include the missing status codes, I dont think 428 is the only one missing
regards
Mike
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks
I'll use the workaround for now, any idea if the 'HttpServletResponse ' is going to be updated to include the missing status codes, I dont think 428 is the only one missing
regards
Mike
