Forum Discussion

MaximStanovov's avatar
MaximStanovov
Occasional Contributor
8 years ago

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() mockReque...
  • MaximStanovov's avatar
    MaximStanovov
    8 years ago

    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)
    }