1

The description for FormData.append() reads as follows:

(method) FormData.append(name: string, value: string | Blob, fileName?: string):void

The function below is simply just appending two string literals to a FormData object and posting it to a C# controller. The issue is that my controller is receiving the key but not the value.

I can successfully get a key and value when my value is a blob, such as file data. But I cannot get the value when it is a string (or string literal, as shown in the demo below). It is simply empty.

deleteSelectedFiles(url, data, files, method = "POST") {
    var that = this;
    let formData = new FormData();

    for (let i = 0; i < data.length; i++) {
        formData.append("test", "wow");
    }
    console.log(formData);
    return this.http.fetch(url, {
        method: method,
        body: formData,
        headers: new Headers()
    }).then(response => response.json()
        .then(function (response) {
            if (response) {
                that.refreshTable();
            }
            else {
                console.log("upload() response: " + response);
            }
        }));
}

I have the following Http Fetch Client that I've been using to do many different kinds of tasks without any issues, so I don't believe the issue is with the configuration.

http = new HttpClient();
http.configure(config => {
        config
        .useStandardConfiguration()
        .withBaseUrl(``);
8protons
  • 3,591
  • 5
  • 32
  • 67

0 Answers0