Multipart Form Data with Forge Remote

Hi!
Ho do I post a multipart form data request to a remote endpoint with forge remote, invokeRemote in the frontend of the custom UI kit React app?
I constantly get back 400 from the backend that is accepting multipart form data.
What should I do?

    const formData = new FormData();
    formData.append('officeName', currentOfficeData.officeName);
   .....
    invokeRemote({
      method: 'POST',
      path: '/office',
      body: formData,
      headers: {
        'Content-Type': 'multipart/form-data',
      },
    }).then((response) => {
      console.log(response);
    });

Thank you!

Hi @GyorgyVARGA,

Based on my understanding, you are getting an HTTP 400 as a response from the remote host, not an invocation from your Forge app, right? Are you the developer of said backend? I would recommend checking the implementation and debugging from that end; generally 400 is due to a malformed body data or unexpected data in general. It’s difficult to assume what goes on the backend without further context, but I would start there.

Cheers

Hi @GyorgyVARGA , unfortunately invokeRemote only supports a JSON body at the moment. If it is important for you to have support for other content types, I would suggest raising a ticket here and upvoting it.

2 Likes

Sorry @BoZhang, I think you didn’t link what you wanted in your second link in your response. Can you please correct it?