我从RestSharp The URI prefix is not recognized
获得例外,无法找出原因。
参数
requestBody
只是一个POCO
domain
是some.company.com
和
_config.AddPersonEndpoint
是api/person/add
public PersonResponse AddPerson(PersonRequest requestBody, string domain)
{
var client = new RestClient(domain);
var request = new RestRequest(_config.AddPersonEndpoint, Method.POST);
request.RequestFormat = DataFormat.Json;
request.AddBody(requestBody);
var response = client.Execute<PersonResponse>(request);
if (response.ErrorException != null)
throw response.ErrorException;
if (response.ErrorMessage != null)
throw new PortalConnectivityException(response.ErrorMessage);
if (!string.IsNullOrEmpty(response.Data.ErrorMessage))
throw new PortalException(response.Data.ErrorMessage);
return response.Data;
}
答案 0 :(得分:3)
您需要确保包含http://
或https://
之类的URI前缀。只是发送网址some.company.com/api/person/add
而不是http://some.company.com/api/person/add
会导致此错误