BugsBunny
BugsBunny

Reputation: 99

grinder print response text

I want to print the last response from my GET request using Grinder, here is my code:

response_string = httpUtilities.getLastResponse().getText()
print str(response_string)

I got exception:

 'ascii' codec can't encode character u'\ufffd' in position 
  1: ordinal not in range(128) at this line : 

    print str(response_string)

My question is how to convert java.lang.String .

I got from httpUtilities.getLastResponse().getText() into python string? Response has charset='utf-8'

Upvotes: 1

Views: 384

Answers (2)

kirti
kirti

Reputation: 40

I had got the exact same error.. Here's a tweak for this kind of response..

try:
   safe_str = response_string.encode('ascii', 'ignore')
   print("text: "+safe_str)

This will definitely work. :)

Upvotes: 1

Travis Bear
Travis Bear

Reputation: 13869

No conversion should be required. Change

    print str(response_string)

to

    print response_string

Upvotes: 1

Related Questions