使用REST服务器中的GET方法发送参数

时间:2017-07-13 09:30:06

标签: c# rest visual-c++ casablanca cpprest-sdk

我有简单的REST服务器GET方法:

    public class PersonController : ApiController
    {
        // GET: api/Person
        public IEnumerable<string> Get()
        {
            return new string[] { "value1", "value2" };
        }
...
}

它适用于cpp rest client:

http_response httpResponse = httpClient.request(methods::GET).get();
    if (httpResponse.status_code() == status_codes::OK)
    {
        wstring output = httpResponse.extract_utf16string().get();
        wcout << output << endl;
    }

我决定在执行GET时传递一些参数并在以下位置进行了更改:

客户端:

http_response httpResponse = httpClient.request(methods::GET,L"HELLO").get();

服务器:

public IEnumerable<string> Get([FromBody]string value)

[FromBody]string value我从POST方法开始,并期待它能够正常运作。

不幸的是,客户端调用现在没有来自服务器端的响应。我可以将GET与参数一起使用吗?我做错了什么?

UPD:

我已删除[FromBody],但仍有来自客户端的响应400

public IEnumerable<string> Get(string value)

0 个答案:

没有答案
相关问题