i need to add a field to the content of a file (eg filename.pdf.txt). i keep getting a 400 status response, Bad Request.
as it was not immediately clear how to pass a template when uploading a file (hint: make a new FormData.append('template', '<template-name>'), i report here what i’m doing.
my workflow right now is:
make POST request and add file and file template
if operation goes well, make PATCH request and pass object to above created file
i tried adding also .txt after the <filename>, still error.
the filename is retrieved from the response of the POST call, under response.data.filename.
the PATCH object i pass to the body of the xhr call is
{ key: 'value'}
i tried to pass the above object also as JSON.stringify, no better luck.
i also tried to directly add another field in the FormData with the content i want to write, but that POST action takes only the template argument as optional argument.