Quickly converting POST requests to multi-part???



  • Ok, so I'm working on a WebAPI project which has many very large (60+ fields) POST requests to submit data on various forms. Currently, these POST requests are not multi-part. However, the feature I'm working on is a way to attach files to the form submission, which means they have to be converted to multi-part and have the file data added for testing purposes.

    I'm finding that there are basically zero tools out there that take a non-multipart POST request and convert it into a multi-part POST. Fiddler ain't got nothing, I couldn't find anything on the web. The front-end isn't going to be modified to support this feature until later, and I have no idea how to modify it to use multi-part (setting the enctype on the FORM tag does nothing-- I'm guessing whatever JS framework they're using ignores that and builds FORM POSTs from scratch.)

    So... has anybody written a quick and dirty tool for this? Is there a Fiddler plug-in? Today I manually crafted one using some Excel voodoo, it took ages, and I won't be able to use the same one tomorrow after I re-login.

    If I can quickly set the POST to multi-part, I can paste-in a pre-recording of the file I'm uploading and have Fiddler make the request for me. The problem is the first step.



  • Is it possible for you to upload the file using an ajaxy uploader. get file metadata and attach it to the form as another input field.



  • That part is trivial. The harder part is converting the 61 fields to multipart format.



  • What I am suggesting is that the file upload will be handled separately and not as part of the main form submission.

    1. user attach a file to the form
    2. file get uploaded in the background
    3. on successful upload file reference( id, url, etc) is returned and added as a hidden input field to the form.
    4. user submit the form normally( without the the actual file data being transmitted just the file reference a string )

    no need to convert the form to multi-part in that case.



  • Oh for Christ's sake, no I'm not changing the entire design of the project. I just wanted a quick and dirty way to test my code.



  • @blakeyrat said:

    Oh for Christ's sake, no I'm not changing the entire design of the project. I just wanted a quick and dirty way to test my code.

    If all you need is to test your back-end code with a simple upload, data tampering and transformation on the network level, plugins, 3rd party tools and excel voodoo does seem like you are on the right path for a dirty but far a way from quick.
    changing the entire project design as you call it could be quicker than that.

    In the case the data being submitted by the form is AS-IS and is not modified by custom submit handler.
    The quick thing to do is to override or bypass, The "custom submit handler" and let the default browser handle the submit where enctype attribute is taken into account.

    Don't thank me



  • @Monarch said:

    changing the entire project design as you call it could be quicker than that.

    Do you people understand the concept of making the minimum change to accomplish the goal?

    @Monarch said:

    In the case the data being submitted by the form is AS-IS and is not modified by custom submit handler. The quick thing to do is to override or bypass, The "custom submit handler" and let the default browser handle the submit where enctype attribute is taken into account.

    It's in a hipster JS MVC framework. I already tried that approach for a half hour and gave up on it.



  • Can you alter the raw POST data at the receiving server (using C# or whatever backend language you're using), or does it need to be altered before it hits the server?



  • The latter. In case of a multipart POST, I switch to a streaming WebRequest reader, and that bit of code needs testing too.

    Since you people are all useless, I'm just going to write a quick and dirty WinForms app to do what I need when I get in. Just as fast as the Excel solution and easier to cope with.


  • Java Dev

    It's probably easiest to use a local scratch HTML page to submit the form from. I know pretty well how multipart works, but I'm not aware of any toolings.



  • The auth is pretty irritating to set up.

    I'm mostly just shocked fiddler doesn't have a button for this.




Log in to reply