Forum Discussion

xikandar's avatar
xikandar
Occasional Contributor
7 years ago

How to pass application/x-www-form-urlencoded requst in ReadAPI having plus sign '+' in request body

REST request doesn’t work and 400 Bad request is received in response from server when following request is sent in body with Media Type x-www-form-urlencoded. However sometime this services works pr...
  • PaulMS's avatar
    PaulMS
    7 years ago

    You could add refresh_token and token_type as query parameters.

    There is a similar example in Soap UI documentation using the Post QueryString check box.

     

    https://www.soapui.org/rest-testing/understanding-rest-parameters.html

    For such requests, you can include parameters of the QUERY type into the request body. To do this, simply select the Post QueryString check box.

    This will remove QUERY parameters from the URL and will add them to the request body. 

     

    You could also use groovy script to encode data directly in the body of the request.

     

    Wrap the request data or just the token like this

    ${= java.net.URLEncoder.encode('string', "UTF-8")}

     

     

    https://www.soapui.org/testing-dojo/best-practices/understanding-rest-headers-and-parameters.html

    Character Encoding
    Special characters are encoded in the URL, by a mechanism called “percent encoding”. In this mechanism any character can be replaced by the percent symbol, followed by a two-digit hexadecimal value of the encoded character. If special characters (such as the hash character) need to be sent as actual data, they must be encoded. All other characters can optionally be encoded.