bruno icon indicating copy to clipboard operation
bruno copied to clipboard

[Bug] Variables in the body with multipat form type.

Open Solovyov opened this issue 1 year ago • 24 comments

Variables are not inserted into the body with multipat form type.

mock return request body image

Solovyov avatar Oct 04 '23 15:10 Solovyov

Seems similar to #329, I'll see if this is the same kind of quick and easy fix.

lared avatar Oct 04 '23 15:10 lared

Sorry, it's a bit more difficult fix - by the time we are interpolating things, we are already using Axios magic

{
  "method": "POST",
  "url": "http://google.com",
  "headers": {
    "content-type": "multipart/form-data; boundary=--------------------------197003115612960382152288"
  },
  "data": {
    "_overheadLength": 206,
    "_valueLength": 11,
    "_valuesToMeasure": [],
    "writable": false,
    "readable": true,
    "dataSize": 0,
    "maxDataSize": 2097152,
    "pauseStreams": true,
    "_released": false,
    "_streams": [
      "----------------------------197003115612960382152288\r\nContent-Disposition: form-data; name=\"whatever\"\r\n\r\n",
      "{{someVar}}",
      null,
      "----------------------------197003115612960382152288\r\nContent-Disposition: form-data; name=\"\"\r\n\r\n",
      "",
      null
    ],
    "_currentStream": null,
    "_insideLoop": false,
    "_pendingNext": false,
    "_boundary": "--------------------------197003115612960382152288"
  },
  "script": {},
  "vars": {},
  "assertions": [],
  "cancelToken": {
    "promise": {}
  }
}

To fix this we'd need to either:

  • dig through the guts here, it might be that just interpolating _streams is enough (we already dig in the guts of json, and x-www-form-urlencoded bodies, but here you need to make sure that it works in all cases)
  • interpolate it first and then feed it through axios, but there is some conditional logic in between that needs some love, and there's a lot of manual testing to get things right

It's not very complicated, just requires more time than I have at the moment.

lared avatar Oct 04 '23 16:10 lared

I love Bruno's design and integration with projects/repos. I would've incorporated it into my project today if I hadn't run into this. Very much looking forward to this fix.

adleatherwood avatar Nov 03 '23 15:11 adleatherwood

Same here, looking forward to this fix!

Schoof-T avatar Nov 21 '23 09:11 Schoof-T

Yes, same here indeed: it would be much more elegant to be able to.

EmmanuelRoubion avatar Nov 21 '23 10:11 EmmanuelRoubion

Any progress on this issue?

t-jans avatar Dec 05 '23 10:12 t-jans

Any progress on this issue?

Not really. I try (or somebody else) to look into it the next few days. But i think it should be a relatively easy fix™.

Its-treason avatar Dec 05 '23 11:12 Its-treason

Thanks for taking the time @Its-treason. I'll build it locally to try the fix 👀

peauc avatar Dec 20 '23 13:12 peauc

@peauc Any progress?

Schoof-T avatar Jan 22 '24 16:01 Schoof-T

Just ran into this, looking forward to this being fixed

dgiessing avatar Feb 20 '24 09:02 dgiessing

Same here, I will probably find a workaround using axios directly however looking forward to the fix

Sebastian-Lerch avatar Mar 01 '24 13:03 Sebastian-Lerch

Having same issue. You can do the following (.bru file):

...
headers {
  Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW
}

body:text {
  ------WebKitFormBoundary7MA4YWxkTrZu0gW
  Content-Disposition: form-data; name="grant_type"
  
  client_credentials
  ------WebKitFormBoundary7MA4YWxkTrZu0gW
  Content-Disposition: form-data; name="client_id"
  
  {{MyClientId}}
  ------WebKitFormBoundary7MA4YWxkTrZu0gW
  Content-Disposition: form-data; name="client_secret"
  
  {{MyAppSecret}}
  ------WebKitFormBoundary7MA4YWxkTrZu0gW
  Content-Disposition: form-data; name="resource"
  
{{MyResource}}
  ------WebKitFormBoundary7MA4YWxkTrZu0gW--
}
...

This example has 4 parts:

  • grant_type
  • client_id
  • client_secret
  • resource

mstroppel avatar Mar 04 '24 06:03 mstroppel

I have the same issue, Is it possible to get a solution for this bug?

xosealvarez avatar Mar 07 '24 10:03 xosealvarez

For those looking for a workaround in the meantime, switching to body type 'Form URL Encoded' and adding the same params with variables there worked for me.

robert-smith-maersk avatar Apr 24 '24 14:04 robert-smith-maersk

@lohxt1 Assigning this to you. Please get to speed on this issue and lets review @Its-treason PR if we can get to a solution that does not involve a breaking change

helloanoop avatar May 15 '24 10:05 helloanoop

Any updates?

xosealvarez avatar Jun 05 '24 10:06 xosealvarez

there is a pr that fixes this issue. it resolves the multipart form data interpolation issue without introducing any breaking change, the approach taken here involves deconstructing the form data and recreating it back using the interpolated values. the pr is yet to be reviewed

lohxt1 avatar Jun 05 '24 10:06 lohxt1

For those looking for a workaround in the meantime, switching to body type 'Form URL Encoded' and adding the same params with variables there worked for me.

This doesn't work for me, using Bruno CLI

@sanjai0py

irharrier2 avatar Jul 09 '24 13:07 irharrier2

Any updates please team? I'm using latest Bruno, no joy.

matthewb531 avatar Jul 25 '24 10:07 matthewb531

Also running into this issue. The work around to use "Form URL Encoded" won't work for me as I need to upload a file 😢 thanks to everyone working on this, #2329 seems promising!

zacharyjarnagin avatar Aug 10 '24 17:08 zacharyjarnagin

I have the same issue, would love to have a fix or a workaround that allows to upload files while using variables

vagneurf avatar Aug 13 '24 09:08 vagneurf

Loving Bruno - this bug is painful for me right now.

adobitar avatar Aug 16 '24 18:08 adobitar

Yes! This bug is really painful.

ejsmith avatar Aug 16 '24 19:08 ejsmith

Is there any update on this? This bug is frustrating.

ali-transmedia avatar Aug 19 '24 05:08 ali-transmedia