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

Copy as Curl, items that are Body>form-url-encoded do not receive curl's --data-urlencode #316

Open
sprive opened this issue Mar 5, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@sprive
Copy link
Contributor

sprive commented Mar 5, 2025

The "Copy as Curl" feature, in cases when you have data that needs URL encoding (meaning you set "Body>form-url-encoded" fields in RF), is exporting the command without the equivalent --data-urlencode (it uses `--data="..." for every field).

Impact:
If your Restfox body fields contained URL-unsafe characters ($, @, etc.) then the exported curl will not send data correctly, and you will likely receive an API response error.

Workaround:
If you manually change --data= to --data-urlencode= then the exported command works.

Possible solutions:

  1. Just use --data-urlencode for almost everything.
    With curl, it always does the right thing with --data-urlencode= (if no URL unsafe characters exist, then the data is 100% identical to what's sent using --data=. The only corner issue I see is if the RF user had manually "pre-encoded" their data, using shell commands, which seems unlikely)

  2. You could trigger this off RF's Body "type" setting provided by the user, and use what you know about body types to automatically set fields for curl data.

EXAMPLE STEPS:

  1. In POST Body, I have client_id, client_secret, grant_type and "Form URL Encoded"
  2. client secret field, I set to "ASDF%z...redacted...2@#diy" (note: has url-unsafe special chars)
  3. Restfox posts this fine (encoded) to the API. No API error.
  4. Do the "Copy as Curl", there's no encoding specified on these fields. API will return an error.

exported curl: ```
curl --request POST
--url https://example.com/oauth/token
--header 'content-type: application/x-www-form-urlencoded'
--data client_id=myusername
--data 'client_secret=PMY%...redacted...2@#diy'
--data grant_type=client_credentials


@flawiddsouza flawiddsouza added the bug Something isn't working label Mar 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants