How to use the Search API in SDL LiveContent Reach?

Hi,

I want to use XQuery (Search API) provided by SDL reach.

Following is the URL that I found from the documentation.

http://<host>:<port>/<context>/web/search.xql?action=search&min=<value>&chunk=<value>&max=<value>&sort=<value>&scope=<value>&query=<value>&searchId=<value>&format=<value>&lang=<value>&pub=<value>&filter=<value>

I want to know the proper way to access this API from C#

I tried using HttpClient, and tried to read the response using ReadAsStringAsync () method, but this gives me an error.

Please could you assist me with this, as I want to format the search result I get from the API.

Regards,

Puneet Singh Marwaha

Parents Reply Children
  • Hi Puneet,

    That means that you need indeed C#. I had almost something for PowerShell but I'll explain what you need to do to authenticate yourself to the API. That means capturing a set of cookies (JSESSIONID) that grants you access to the api.

    The following is assuming your target Reach is deployed and configured for Review and Collaboration and that means it is using the same STS as Content Manager. As I don't know your STS I'll be generic

    You have a couple of options:

    • From the C# play browser and where necessary fill in the credentials if necessary. You can use WebClient class or more low level classes such as HttpClient or WebRequest. An excellent guide is looking at Fiddler while you do the same from your browser
    • From the C# launch a browser, let it authenticate and somehow capture the cookies after it gets authenticated to Reach
    • From the C# get a token using WCF and WSTrust from the configured STS and then submit the token to Reach and capture the cookies. Again Fiddler is an excellent guide. If you chose this path then let me share a small but important detail. Before you issue the token, you need make a request to Reach and capture an initial JSESSIONID cookie. Then when submitting the token you need to pass this original JSESSIONID and then capture the replacement. This is all in Fiddler captures but its a small detail and you need to be aware to notice.

    The code for each case is not easy and it is beyond the scope of this thread. Please take notice that working with the protocols for federated authentication is an advanced subject. But as reference WS-Federation and WS-Trust are in play.

    An alternative that is to discuss with the owner of the Reach deployment to open up a potential alternative root for your application and only your application. This is a security violation and therefore not my preference and certainly not the path I would chose.

    Good luck and let me know if I can help further within the scope of this thread.

  • Hey Alex,

    Thank you so much for this info and your time.
    However this knowledge isn't sufficient for us to implement. It would be better if we could have a little snippet of what you explained above.
    But I understand the scope of this thread does not ask for it.
    Could you also please specify posts which could help me implementing it.
    Any help will be appreciated.
  • Hi Puneet,
    As I already mentioned, providing the solution is beyond the scope of this thread. From my explanation it should be already clear that this is not simple and therefore it cannot be provided as part of some snippets. In other words, it simply doesn't fit plus I don't a have a clean code base to share.

    My advice is to look online for what I mentioned. Search for the terms provided but keep in mind that you need relatively good understanding of SOAP and WCF. I'm a person that likes to see what is going on on the network layer and if you share my preference, then while using Publication Manager, capture a session with Fiddler and analyze it.

    I've also shared a PowerShell module WcfPS  that addresses only part of what you need. It can issue bearer tokens for web sites but the rest becomes your responsibility.

    Good luck
    Alex

  • Hi Alex,

    Thanks again for replying.
    Will try to find to some solution from the details you have provided.

    Also, I am not able to open the link you have shared for Power Shell.
    When I click the url, it says page not found.

    Regards
    Puneet