Skip to content
This repository has been archived by the owner on Jun 27, 2019. It is now read-only.

Encode Spaces as "+" rather than "%20", for form-encoded requests. #161

Closed
condad opened this issue Oct 17, 2017 · 1 comment
Closed

Encode Spaces as "+" rather than "%20", for form-encoded requests. #161

condad opened this issue Oct 17, 2017 · 1 comment
Assignees
Labels

Comments

@condad
Copy link

condad commented Oct 17, 2017

Many legacy systems expect spaces to be encoded with a "+", rather than "%20".

To reproduce this issue, submit the same form-encoded request (with spaces) with CLI Zapier app and with a command line tool like cURL or HTTPie. Afterwards, compare the request bodies to see the difference.

@BrunoBernardino BrunoBernardino self-assigned this Nov 14, 2017
@BrunoBernardino
Copy link
Contributor

Thanks for this @condad, and I'm sorry for the late reply here.

We'll release a new (probably backwards-breaking) version fixing this, but for now, an alternative is to send the body as a string, which we won't tamper with:

z.request({
  url: 'https://...',
  method: 'POST',
  headers: {
    'content-type': 'application/x-www-form-urlencoded'
  },
  body: Object.keys(bundle.inputData).map((key) => `${key}=${encodeURIComponent(bundle.inputData[key]).replace(/%20/g, '+')}`).join('&')
});

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants