Restsharp 异常无法识别 URI 前缀

vig*_*ity 1 c# restsharp

我从 RestSharp 得到一个例外,但The URI prefix is not recognized不知道为什么。

参数

requestBody 只是一个 POCO

domainsome.company.com

_config.AddPersonEndpointapi/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;

}
Run Code Online (Sandbox Code Playgroud)

vig*_*ity 5

您需要确保包含 URI 前缀,例如http://https://。只发送 urlsome.company.com/api/person/add而不是http://some.company.com/api/person/add会导致此错误