I am trying to post binary data using the code below :
let headers = new Headers()
headers.append('Content-Type', 'application/json')
this.http.post("http://localhost:8080/api/load",
requestBytes,
{
headers: headers
}).subscribe((data) => {
console.log("success!!!")
})
requestBytes
is of the type Uint8Array
The request payload looks like this
{
"0": 10,
"1": 1,
"2": 49
}
As you can see this appears to be a dict while I was anticipating it to be a byte array. This causes confusion on the server.
I tried changing the Content-Type
to application/octet-stream
and passing in the buffer
instead of array but that didn't help too. The payload in that case is coming out to be empty.