I'm developing a project with TMS Web Core and need to make a POST request to my API to send an image. My API requires the request body to be in multipart/form-data format, so I can't use JSON.
I've tried using the TJSFormData object to build the request body, as recommended for this type of task. However, I can't find the TJSFormData class in any of my project's libraries or units, which prevents me from adding the form fields and the image file to attach them to the TWebHttpRequest parameters.
Could you tell me the unit or library where the TJSFormData object is located, or failing that, what is the correct method to send form-data with an image to my API using TWebHttpRequest?
At this moment there isn't a built-in Pascal class to automatically create the data stream required for multipart form data.
The fastest way to integrate this in a TMS WEB Core app is by reusing & embedding the equivalent JavaScript code in an ASM block.
Okay, I understand that I should create a .js file containing the JavaScript function that will execute the request, and in my Pascal procedure, create an ASM code block to call the JavaScript function.
The only question regarding this is, if I want to call the function within my ASM code, can I import the .js file with the function I need to call as another unit in my .pas, or do I have to import it within the ASM block, as JavaScript ( import { postMultipartBrowser } from './postMultipartBrowser.js';)