andisan
andisan

Reputation: 77

Cypress: Parameter with square bracket in the body of cy.request()

I am trying to put parameters with a square bracket into the body of cy.request(). Seems that this is invalid, is there a way around this?

cy.request({
  method: 'POST', 
  url: 'https://api.stripe.com/v1/payment_pages',
  form: true,
  body: {
      guid: 'NA',
      muid: '32f745f3-9b97-4414-ae8d-9cbb349ff90f39306f',
      sid: 'f5522056-b497-43d1-8a5f-9cbc0ccc41a5400050',
      items[0][type]: 'price',     =====>> THIS
      items[0][id]: 'sku_GU4JYXyvvRb2sX', 
      items[0][quantity]: '1',
      mode: 'payment',
      success_url: 'https://stripe-samples.github.io/github-pages-stripe-checkout/success.html?session_id={CHECKOUT_SESSION_ID}',
      cancel_url: 'https://stripe-samples.github.io/github-pages-stripe-checkout/canceled.html?session_id={CHECKOUT_SESSION_ID}',
      use_payment_methods: true
  }
})

Upvotes: 1

Views: 621

Answers (1)

andisan
andisan

Reputation: 77

I was able to escape this parameter by adding double-quotes around it.

Upvotes: 1

Related Questions