Skip to content
This repository was archived by the owner on Sep 26, 2022. It is now read-only.

Send empty query parameters (without "=") #226

Open
Acousticdesk opened this issue Jan 31, 2022 · 0 comments
Open

Send empty query parameters (without "=") #226

Acousticdesk opened this issue Jan 31, 2022 · 0 comments

Comments

@Acousticdesk
Copy link

Acousticdesk commented Jan 31, 2022

Greetings! Thanks for the great tool to send http requests in capacitor applications!

I would like to request a feature to send empty query parameters without the equal sign since currently, the only option is to send a parameter with an empty string that results in ?parameter=&otherParameter=1 instead of ?parameter&otherParameter=1.

Example:

Http.request({
  method: 'POST',
  url: environment.serverUrl,
  headers: {
    'Content-Type': 'application/xml'
  },
  data: xmlPayload,
  responseType: 'text',
  params: {
    parameter: '', // null or undefined will result in an error
    otherParameter: environment.version,
  }
})

To solve it probably the plugin should respond to null values as empty values and create a query string as ?parameter&otherParameter=1.

{ parameter: null, otherParameter: environment.version }

Additional context:

Currently, we are integrating with a 3rd party service that only accepts the first query parameter without any additional symbols after it, including "=".

Having query parameters without equal sign seems to be a valid thing, please check the thread below that includes cites from specification:
https://stackoverflow.com/questions/4557387/is-a-url-query-parameter-valid-if-it-has-no-value/4557763#4557763

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

No branches or pull requests

2 participants
@Acousticdesk and others