0

I'm trying to parse my URL with wildcards. The problem appears when I try to parse long strings with a wildcard. For example, my URL looks like this:

http://testapi.com/v1/cards/%s/reissue?DesignId=%s&Comment=%s

and this is my code:

get_object.setRestUrl(String.format(url, card_id, design_id, comment))

When comment = "Something" it works, but when comment = "Something something", it goes on an error and says that it is "Unable to parse HTTP request".

How is it possible to make suitable my code with long strings with wildcards? I know that when typing long string it gives URL that looks like this:

http://testapi.com/v1/cards/1/Block?reasonId=1&comment=Something%20like%20that%20example
Mate Mrše
  • 7,997
  • 10
  • 40
  • 77
brithwulf
  • 538
  • 10
  • 35

2 Answers2

1

Just needed to modify with comment.replace(" ", "%20"), and now it works fine, even when there are no spaces.

Source : https://forum.katalon.com/t/getting-an-error-unable-to-parse-http-request/17685

P.S If it is not allowed to post answer from another site, I will remove it.

brithwulf
  • 538
  • 10
  • 35
  • 1
    It is allowed. However, you are encouraged to write the important part of the solution, so the answer remains on SO even if the outside link is removed. – Mate Mrše Jan 14 '19 at 14:50
1

You could try it:

get_object.setRestUrl(String.format(url, card_id, design_id, comment.replace(" ", "%20")))

More information could be found at https://forum.katalon.com/t/getting-an-error-unable-to-parse-http-request/17685

Tony Bui
  • 815
  • 5
  • 7