Forum Discussion

xikandar's avatar
xikandar
Occasional Contributor
7 years ago
Solved

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 properly and 200 status code is returned. After hours of investigation it is found that when request contains plus symbol ‘+’ then SoapUI doesn’t send it properly hence 400 is received. When request doesn’t contain + symbol then it works fine.

Problem here is that refresh_token value is auto generated from server and we can’t skip the + symbol . So kindly help me to find a way how can I send following request with Media Type x-www-form-urlencoded without any problem


Note: If I run following request in Postman it works perfectly, so there is some problem with ReadyAPI not sure it’s a bug or what. Find the attached screen shots that explain all the situation and to get more idea of the problem.


refresh_token=QUVTMjU2LUdDTXz6wnrEQqgykoL2utxcoI/tk2zNfptgDg1vjx2hMsjP4NxbQ4oCuaVlqf2FV/71+HOdz8CkfppeNNyuqEpb5KM=
&token_type_hint=refresh_token

  • 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.

6 Replies

  • PaulMS's avatar
    PaulMS
    Super Contributor

    Is the plus sign encoded in the request Raw tab?

    • xikandar's avatar
      xikandar
      Occasional Contributor

      NO, it is not being encoded that's what makes me worried. Even by passing the Media-type "application/x-www-form-urlencoded" still the request is being sent as it is by ReadAPI without encoding. See the attached image.

      Is there any way to get it done ?