I'm trying to send a file and json object via post method. Code sample :
serviceFunction(file, jsonObjAlreadyStringified){
const url : 'something'
const params: 'some params'
const reqBody: FormData = new FormData();
reqBody.append('file',file)
reqBody.append('json', jsonObjAlreadyStringified)
return this.http.post(url, reqBody, {params, responseType: 'arrayBuffer'});
}
I managed to hit the server, but was getting 415 unsupported media. Tried and postman and it worked after I specified the 'json' content-type as "application/json"
So my question is, how do I define the content-type for the json and send it along with the file?