I am trying to upload pdf files to webform submission using REST API.

Since the Core File Upload functionality did not seem applicable for webform submission, I applied the patch from webform_rest module which would allow uploading files for webform submissions.

When POSTing the file via /webform_rest/{webform_id}/upload/{field_name} with the necessary Content-Type and Content-Disposition, Cookie and X-CSRF-Token per documentation, the file entity response's filesize value is always zero and correspondingly the destination file is empty. The file size and extension are in accordance to the settings in webform's Document file field. The public, private and tmp directories are writable and file upload works fine when performed through the webform submission form.

I tried to check if this issue is specific to the webform_rest resource by trying the File upload resource (/file/upload/{entity_type_id}/{bundle}/{field_name}) for a specific entity type with the respective file field and observed the same result of file being empty. To try and understand where the issue might be I looked into both the Rest resource code and tried checking the symfony $request->files parameter which appears to be empty in both cases.

Since the file upload functionality works fine within the site and related php configurations like file_uploads, upload_max_filesize, post_max_size are already set I'm uncertain as to how to approach this problem further

Would request some clarity on how I could debug this further and get it to work.

1 Answer 1


Tried to check if the API behaved differently when hit through cURL instead of the Postman app which I had been relying on and it worked immediately. Realized it was an issue with either my workplace network preventing the file upload through postman or problem within the version of postman installed in my work computer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.