Search code examples
c#versionone

VersionOne Unknown AssetType


I'm trying to use the VersionOne API via the C# APIClient, but my meta model is only getting an Unknown AssetType error wrapping a 405 exception. What am I doing wrong? Here's a code snippet:

VersionOneAPIConnector conn = VersionOneClientFactory.CreateClient(Endpoint.Data);
conn.WithVersionOneUsernameAndPassword("username", "password");
IMetaModel meta = new MetaModel(VersionOneClientFactory.CreateClient(Endpoint.Meta));
Services s = new Services(meta, conn);

If it helps, here's the CreateClient method:

public static VersionOneAPIConnector CreateClient(Endpoint e)
{
    StringBuilder url = new StringBuilder("https://www#.v1host.com/MyCompany/");
    switch (e)
    {
        case Endpoint.Data: url.Append("rest-1.v1"); break;
        case Endpoint.Localization: url.Append("loc-2.v1"); break;
        case Endpoint.Meta: url.Append("meta.v1"); break;
        case Endpoint.Query: url.Append("query.v1"); break;
    }
    return new VersionOneAPIConnector(
        url.ToString(),
        proxyProvider: new ProxyProvider(
            new Uri("http://proxy.server"),
            "proxy_username",
            "proxy_password"
    ));
}

Here's what I see in Visual Studio:

Debugging in Visual Studio

In this case I use a breakpoint to show you the issues in the Locals window. If I were to actually try to do anything, the MetaException gets thrown.


Solution

  • This seems to fix it:

    proxyProvider: new ProxyProvider(
        new Uri("https://proxy.server:port"),
        "proxy_username",
        "proxy_password"
    )
    

    I could've sworn whatever example I was using said to not include port. Apparently that was fallacious. Sorry for the trouble guys, but thanks for trying to help!


    Also, verified that mkunzi's answer is valid too. You need the slashes at the end of the endpoints (e.g. "meta.v1/") or it won't work.