I’m sending a post request to the web service but getting the error “forbidden”. Below is my code
getSearchResults1(term: string){
let data= JSON.stringify({searchString:term});
let headers=new Headers({'Content-Type':'application/x-www-form-urlencoded'})
let options = new RequestOptions({headers:headers});
this.http.post(myUrl,data,options)
.map(res =>res.json())
.subscribe(data =>{
console.log(data);
});
}
The error I’m getting on console is:
But when I’m manually entering the url with post data appended to it like: myUrl?searchString=Trump, I get the response from web service. I can’t get to the root of the issue.
When you manually write in the data in the URL in your browser it’s a GET request, are you expecting a GET or a POST request in your backend? You should try out Postman to test this kind of stuff really easily
If I throw single post on that URL I get proper response
POST /searcharticle2 HTTP/1.1
Host: regulatorynavsvc-dev.pwc.com
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3087.0 Safari/537.36
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW
Cache-Control: no-cache