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

Request of type FormData does not work in DemoPanel #618

Closed
jk8 opened this issue Aug 30, 2023 · 5 comments
Closed

Request of type FormData does not work in DemoPanel #618

jk8 opened this issue Aug 30, 2023 · 5 comments
Labels
bug Something isn't working

Comments

@jk8
Copy link
Contributor

jk8 commented Aug 30, 2023

Describe the bug

Our API uses a request with a FormData content type to send media files, and I noticed that the "Send API Request" button (in the API Demo panel) doesn't work properly for those requests. In the browser's network panel, I can see that the request payload only contains an initial delimiter (eg ------WebKitFormBoundarytopELwrKuCYnvZxH--) but no content follows.

Expected behavior

The content of the FormData request should be properly serialized.

Current behavior

The content of the FormData request is incomplete. It only contains the initial delimiter, but nothing else.

Possible solution

I found 2 problems in makeRequest.ts source:

  1. The request body is initially serialized to JSON. This probably won't work for binaries.
  const body = request.body?.toJSON();
  1. The request has a Content-Type header set to multipart/form-data but does not contain a boundary separator. No need to set Content-Type - fetch() will set the correct content-type automatically.

I tried to solve this problem for my case here: jk8@796b32e

EDIT: I can't create PR because latest commit of v2.0.0 branch does not work for me at this time and I can't test it.

Steps to reproduce

Context

Your Environment

  • Version used: v2.0.0-beta.3
  • Environment name and version: Chrome 116
  • Operating System and version (desktop or mobile): Linux
  • Link to your project: N/A
@jk8 jk8 added the bug Something isn't working label Aug 30, 2023
@welcome-to-palo-alto-networks

🎉 Thanks for opening your first issue here! Welcome to the community!

@sserrata
Copy link
Member

Hi @jk8, thanks for reporting this issue.

I can't create PR because latest commit of v2.0.0 branch does not work for me at this time and I can't test it.

Can you provide details on the specific issue you're running into?

@jk8
Copy link
Contributor Author

jk8 commented Sep 18, 2023

I tried again and it seems fine. I must have made some mistake last time. Sorry for the confusion. I have opened PR #625

@sserrata
Copy link
Member

Hi @jk8, just checking in to see if the fix worked as expected before we close this issue

@jk8
Copy link
Contributor Author

jk8 commented Oct 12, 2023

yes, it works well. Thank you. It can be closed.

@jk8 jk8 closed this as completed Oct 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants