Rest Sharp Execute<Int> fails due to cast exception

廉价感情. 提交于 2019-12-06 16:30:39

When looking at the response object I found the return value was in Content vs in Data. I found this to be true whenever I was not returning an object or list of objects.

So now when I'm expecting an int, string, bool, etc I use the following and cast the type of the return value:

    public string ProcessRequestWithValue()
    {
        var response = _client.Execute(_request);

        if (response.ErrorException != null)
        {
            throw response.ErrorException;
        }

        return response.Content;
    }

Hope this helps!

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!