Skip to content

Why does cy request with form true with multiple values for a single key results in a wrong url? And what is the workaround? #30328

Discussion options

You must be logged in to vote

Answer to my own question with workaround for whoever ends up here:

import formurlencoded from 'form-urlencoded'

const myform = {user: ['first', 'second']}

const formurl = formurlencoded(myform, {
  skipIndex: true,
  skipBracket: true,
  whitespace: '%20',
})

cy.request({
  method: 'POST',
  url: '/some/url',
  form: true,
  body: formurl,
})

So what would help is if options like { skipIndex: true, skipBracket: true, whitespace: '%20',} are available to cypress as well.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by wieben
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant