Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: Is it possible to send multipart/form-data request? #218

Open
Klarys opened this issue Sep 22, 2023 · 2 comments
Open

Question: Is it possible to send multipart/form-data request? #218

Klarys opened this issue Sep 22, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@Klarys
Copy link

Klarys commented Sep 22, 2023

Hello!
I'm working with an API that requires me to send some files as multipart/form-data. Is this possible to achieve with restish? This is how the command's help looks like:

  ## Argument Schema:                                                                                                                                                                                                              
                                                                                                                                                                                                                                   
    {                                                                                                                                                                                                                              
      id: (string)                                                                                                                                                                                                         
    }                                                                                                                                                                                                                              
                                                                                                                                                                                                                                   
  ## Input Example                                                                                                                                                                                                                 
                                                                                                                                                                                                                                   
    {                                                                                                                                                                                                                              
      "filename": [                                                                                                                                                                                                                
        "string"                                                                                                                                                                                                                   
      ]                                                                                                                                                                                                                            
    }                                                                                                                                                                                                                              
                                                                                                                                                                                                                                   
  ## Request Schema (multipart/form-data)                                                                                                                                                                                          
                                                                                                                                                                                                                                   
    {                                                                                                                                                                                                                              
      filename: [                                                                                                                                                                                                                  
        (string format:binary)                                                                                                                                                                                                     
      ]                                                                                                                                                                                                                            
    } 

I've tried several approaches but I wasn't able to figure out something that works. Some examples:
1.

restish my-api upload-file 650d9c463c92333e6aa6cc0 @file
ERROR: Caught error: not sure how to marshal multipart/form-data
restish my-api upload-file 650d9c463c92333e6aa6cc0 filename: @file
ERROR: Caught error: not sure how to marshal multipart/form-data

I've also tried adding -H "Content-Type: multipart/form-data" to those commands but the result was the same. Am I doing something wrong or is there just no support for multipart/form-data? I will really appreciate any help, thanks!

@danielgtaylor
Copy link
Owner

@Klarys there's no special logic to handle multi-part forms in Restish yet. For now you can use curl to do it, e.g. see https://everything.curl.dev/http/multipart. I'll consider this a feature request to support it in Restish and will see what I can do.

@Klarys
Copy link
Author

Klarys commented Sep 24, 2023

Thank you for answering and considering this as a future feature request. This functionality is crucial for my use case, so it would be really great to see it implemented.

@danielgtaylor danielgtaylor added the enhancement New feature or request label Oct 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants