我正在嘗試使用angular2 for JavaScript,並且我能夠提出Http.get
請求,但是當我試圖提出Http.post
請求時,它將返回415 Unsupported Media Type
錯誤。415不支持的媒體類型angular2
代碼本身非常簡潔,所以我不確定是什麼原因導致了這個錯誤。我將如何解決這個問題?
var headers = new Headers();
headers.append('Content-Type', 'application/json');
console.log(headers.get('Content-Type'))
return this.http.post(this.endpoint_url, data="test.json", headers=headers).subscribe(
function(response){console.log("Success Response" + response)},
function(error){console.log("Error happened : " + error)});
415將幾乎肯定是一些由服務器返回。 – Harangue