[英]Dynamic post call giving error 404 on angular 5
I am making a post call, where post parameter getting from another get call. 我正在进行post调用,其中post参数是从另一个get调用获取的。 If I pass the post parameter manually its working fine. 如果我手动传递post参数,它的工作正常。
doPost(): Observable<any> {
return this.http.post(this.URL+ '/GetEmp', {emp:[{"empId":8106, "name":"xxxxx"}]});
}
But when I am calling it dynamically its showing 404 error 但是当我动态调用它时,显示404错误
doPost(val): Observable<any> {
this.postD = JSON.stringify(val);
return this.http.post(this.URL+ '/GetEmp', {emp:this.postD});
}
Here I am calling like this 我在这里这样打电话
this.configs.doPost(pval).subscribe(
data => {this.post = data['org']},
err => console.error(err),
() => console.log('done loading employee' + this.post)
);
Requirement is that I am making one GET request, through that I am getting the value and populated the drop-down, once I select the value from drop-down, this value needs to use for parameter in post call. 要求是我发出一个GET请求,通过我获取值并填充下拉列表,一旦我从下拉列表中选择了值,该值就需要在调用后用作参数。
Here I am able to get the value from drop-down, but once I am passing it through post request its giving 404
error. 在这里,我可以从下拉列表中获取该值,但是一旦我将其传递给post请求,它就会给出404
错误。
Please help on this. 请帮忙。
hTTP post
requires an object so please dont stringify
it hTTP post
需要一个对象,请不要对其进行stringify
doPost(val): Observable<any> {
return this.http.post(this.URL+ '/GetEmp', { emp: val });
}
Here is the syntax: 语法如下:
post(url: string, body: any, options?: RequestOptionsArgs) :
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.