Route not found error when using webform_rest to upload files I want to upload a file using webform_rest API as described here. #2899902. But it gives me 415 Unsupported Media Type error as you can see in the screenshot.



Here is my code

  methods: {
    addImage() {
      this.dropFiles = event.target.files[0];
    },

    submitResume() {
      const formData = new FormData();
      formData.append("image", this.dropFiles, this.dropFiles.name);

      axios
        .get("https://example.com/rest/session/token")
        .then(tokenResponce =&gt; {
          this.formToken = tokenResponce.data;
        });

      axios
        .post(
          "https://example.com/webform_rest/job_applications/upload/resume?_format=json",
          formData,
          {
            headers: {
              Accept: "json",
              "Content-Type": "application/hal+json",
              "Content-Disposition": "file; filename = full.pdf",
              "X-CSRF-Token": this.formToken
            }
          }
        )
        .then(response =&gt; {
          this.submitForm(response);
        });
    },

    async submitForm(response) {
      if (this.page === "singlejob") {
        var position = this.jobs.title;
      } else {
        var position = this.position;
      }

      let config = {
        headers: {
          Accept: "json",
          "Content-Type": "application/hal+json"
        }
      };

      this.isLoading = true;

      axios
        .post(
          `https://example.com/webform_rest/submit?_format=json`,
          {
            webform_id: "job_applications",
            name: this.name,
            email: this.email,
            position: position,
            resume: response.data.fid[0].value
          },
          config
        )
        .then(response =&gt; {
          this.isLoading = false;
          if (response.data.sid) {
            this.$router.push({
              path: "/thank-you"
            });
          }
        })
        .catch(error =&gt; (this.isLoading = false));
    }
  }


Need help here.
Thanks
I got it working. two things I was missing.


Make sure you accept all the operations / JSON requests from here
/admin/config/services/jsonapi
I was confused with "binary file data". So basically you don't have
to do anything with the file. No formData, No base64, just pass your
file variable as it is.


And it worked.

Thanks