如何在asp.net mvc控制器中传递body参数时调用POST的服务URL?

时间:2017-08-23 06:19:43

标签: asp.net-mvc

我是asp.net mvc的新手 我有一个服务网址,我已经在postman中测试过它。它向我展示了结果。snapshot of the body parameter

但我无法理解,如何在调用服务时以编程方式传递Body参数。

我试过这样的话:

string reqData =" {\" Text \":\"" + text +" \"" +& #34; \"用户ID \" :\" 10098 \",\" EventID \":\" 42 \"}";

请帮忙,因为我对此很陌生。

1 个答案:

答案 0 :(得分:0)

您必须使用http请求获取数据。

getFunction(){
    return this.http.get('URL')
          .map(res => res.json());
}

在前线,

this.'servicename'.getFunction().subscribe(x=>{ 
      this.x = x;
    });