MaximStanovov
8 years agoOccasional Contributor
How to setRequestContent in Mock in OnRequest Script to replace first character (is it a BUG??)
Hey there!
I'm trying to setRequestContent.
I have this code in "OnRequest Script" in my Mock:
def mockRequestContent try { mockRequestContent = mockRequest.getRequestContent() mockRequest.setRequestContent(mockRequestContent) } catch (Exception e) { log.info(e) }
When I send a response to my Mock, I don't get errors at tab "script log", but I get an error at "error log" (see it in attachment).
What is the right way to set request content?
Thx for your answers.
This code works well.
Problem was in my script that I call at mock response.
You can use this code to convert UTF-8-BOM request to UTF-8 without BOM.
def mockRequestContent try { mockRequestContent = mockRequest.getRequestContent() mockRequest.setRequestContent(mockRequestContent.substring(1)) } catch (Exception e) { log.info(e) }