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
  • 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.

Children