4

I am trying to setup an application that will allow management of Topology through a Web API to allow the automated creation and mapping of publications.

I can manually use the topology commands through Powershell but want to achieve the same through a .Net API.

Powershell commands are working on this environment and am able to do the equivalent calls I am attempting in the code

Tridion.TopologyManager.Client is the .dll that allows communication to the client and is used by the Powershell commands.

What I am unsure of is the endpoint that this should be connecting to.

There is the SDL Web Topology Manager site setup in out Dev environment on port 81 (http://localhost:81)

When I use this as the base I am getting errors that the client cant connect. This is the error I am getting when attempting to list Websites.

An error occurred while processing this request.
   at Microsoft.OData.Client.DataServiceRequest.Execute[TElement](DataServiceContext context, QueryComponents queryComponents)
   at Microsoft.OData.Client.DataServiceQuery`1.Execute()
   at Microsoft.OData.Client.DataServiceQuery`1.GetEnumerator()
   at SJP.Tridion.QualificationImport.TopologyService.GetMapping()
   at SJP.Tridion.QualificationImport.Program.TopologySetup()

When attemptint o create website or mapping the client is not throwing any errors but not making any ammends to the topology.

_client.AddToWebsites(new WebsiteData()
{
    Id = websiteId,
    CdEnvironmentId = cdEnvironmentId,
    BaseUrls = baseUrls
});

I am able to use the http://localhost:81/ttmhealth/check which is returning a 200 OK response.

Wondering if anyone has had any success in using this client. And specifically what the expected endpoint should be.

Example Code setting up the client

var url = "http://localhost:81"    
var serviceUrl = new System.Uri(url);
_client = new TopologyManagerClient(serviceUrl);

Tridion Version

  • SDL Web Content Manager Build 9.0.0
  • SDL Web Content Manager Explorer - Build 9.0.0.0
  • SDL Web Experience Manager - Build 9.0.0.0
  • Update Version - 0

Chris

1 Answer 1

7

The easiest way to find out the endpoint URL is to check the Windows environment variable on the CM server using the following PowerShell command: get-item env:tridion_ttm_serviceurl

This should give a value such as: http://localhost:81/ttm201601


Here's some code that I used recently on my Tridion Sites 8.5 environment for getting the Client:

TopologyManagerClient ttm = new TopologyManagerClient(new Uri("http://localhost:81/ttm201601"))
{
    Credentials = new NetworkCredential("Administrator", "my-password")
};

List<CmEnvironmentData> cmEnvs = ttm.CmEnvironments.ToList()

I took a lot of inspiration for my script from Nuno's code here: https://github.com/NunoLinhares/Exploring-Topology-Manager/blob/master/ExploreTopMan/ExploreTopMan/Program.cs

5
  • I did a bit of digging to see where the 'ttm201601' part of the endpoint came from and it appears that this is a configuration setting within Tridion.TopologyManager.Service.dll. If you're using Tridion 8.1 then this is ttm201501. I've not got the Tridion Sites 9+ DLLs to hand to check those. I don't think that this is a supported API though, so things may need to change if you upgrade Tridion. Commented Mar 20, 2020 at 13:21
  • Actually, the Topology Manager (OData) API is considered (semi-)public. That is why it’s versioned (i.e. there is a version number in the URL). Commented Mar 20, 2020 at 14:27
  • That’s good to know, Rick. Is it documented anywhere? Commented Mar 20, 2020 at 14:30
  • 1
    Thanks Jonathan, Exactly the information that I needed. All working as it should now. Commented Mar 20, 2020 at 14:57
  • Excellent. Glad you managed to get it sorted 👍 Commented Mar 20, 2020 at 19:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.