Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect POST requests using application/x-www-form-urlencoded in case XML contains '+' symbol #312

Closed
dreik opened this issue Jul 26, 2024 · 1 comment

Comments

@dreik
Copy link

dreik commented Jul 26, 2024

I'm trying to send request like this

POST /MyApi.asmx/request HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Authorization: Basic {{basicuser}}{{basicpassword}}

xmlRequest=<Request>
    <User>[email protected]</User>
    <Password>randompassword</Password>
    <RequestMethod>GetAvailability</RequestMethod>
    <SearchParameters>
        <Product>1</Product>
        <ShopId>1</ShopId>
        <Currency>USD</Currency>
    </SearchParameters>
</Request>

I'm getting following as the actual request logged in my db:

<Request>
    <User>some.user [email protected]</User>
    <Password>randompassword</Password>
    <RequestMethod>GetAvailability</RequestMethod>
    <SearchParameters>
        <Product>1</Product>
        <ShopId>1</ShopId>
        <Currency>USD</Currency>
    </SearchParameters>
</Request>

Storing User and Password as variables also doesn't work:

  • in case of .env file variable it breaks even mouseover: instead of {{Password}} value it's showing {{User}} value when you do mouseover on {{Password}}
  • in case of local variable it shows nothing on mouseover (additionally tested, and it very looks like that mouseover works in very strange way when you have a mixture of .env file variables and @local variables within same request)

Just to confirm - I've tested same requests in postman, and it works properly, so the issue isn't on the backend side (i.e parsing reqs or storing in sql)

Anyway, your solution is really great and very helpful! Thank you so much !

@AnWeber
Copy link
Owner

AnWeber commented Aug 4, 2024

@dreik for application/x-www-form-urlencoded POST request the body needs to be Percent-Encoded (see MDN). I use encodeUrl package but + signs will not get encoded. You need to do it yourself (see AnWeber/httpyac#677)

POST /MyApi.asmx/request HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Authorization: Basic {{basicuser}}{{basicpassword}}

xmlRequest=<Request>
    <User>some.user%[email protected]</User>
    <Password>randompassword</Password>
    <RequestMethod>GetAvailability</RequestMethod>
    <SearchParameters>
        <Product>1</Product>
        <ShopId>1</ShopId>
        <Currency>USD</Currency>
    </SearchParameters>
</Request>

@AnWeber AnWeber closed this as completed Aug 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants