Hi All,
We've been using Rest API's for Content Server Search for a few years now. We are about to upgrade to CS16, and I am having a hard time making the SAME code work! Since it could be our setup or feature(s) not available in CS16, I will show the browser query which WORKS from the browser:
http://<hostname>/otcs/llisapi.dll?func=search&dspRegion1=OTDataID&dspRegion2=OTName&dspRegion3=OTDataSize&boolean1=and&lookFor1=complexquery&where1=OTLocation:<rootNodeId>&outputformat=xml
where <hostname> is our internal server name, and <rootNodId> is the search root.
Again, this exact query works in CS10 and ALSO works in the browser in CS16.
The SAME query works fine when sent from .Net code in CS10, but fails when sent in CS16 environment.
Here is code sample I am using to send the query, unchanged between CS10 and CS16:
using System;
using System.Diagnostics;
using System.IO;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
namespace ConsoleApplicationWCF{ class Program
{
private const string un = "username", // our username
pw = "password", // our password
queryCommand = "http://<hostname>/otcs/llisapi.dll?func=search&dspRegion1=OTDataID&dspRegion2=OTName&dspRegion3=OTDataSize&boolean1=and&lookFor1=complexquery&where1=OTLocation:<rootNodeId>&outputformat=xml";
static void Main(string[] args)
{
HttpResponseMessage result = null;
using (var client = new HttpClient(new HttpClientHandler() { UseDefaultCredentials = true }))
{
client.BaseAddress = new Uri(queryCommand);
string authentication = Convert.ToBase64String(Encoding.UTF8.GetBytes(un + ":" + pw));
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", authentication);
client.GetAsync(queryCommand).ContinueWith(z => result = z.Result).Wait();
}
string response = String.Empty;
using (Stream receiveStream = result.Content.ReadAsStreamAsync().Result)
{
using (StreamReader readStream = new StreamReader(receiveStream))
{
response = readStream.ReadToEnd();
}
}
Console.WriteLine(response);
Trace.WriteLine(response);
Console.ReadKey();
}
}
}
When I run this on CS16 I get some malformed pages in response:
<!DOCTYPE html>
<html>
<body onload="document.forms[0].submit()">
<noscript>
<p><strong>Note:</strong>Since your browser does not support Javascript, you must press the Continue button once to proceed.</p>
</noscript>
<form action="https://<hostname>/otcs/llisapi.dll" method="post">
<div>
<input type="hidden" name="OTDSTicket" value="*VER2*ABS3wOCSR4O40Uc3UJLleH8_0CblXQAQHPrRX18ZxisUrWclHvQFKgKwnLM-kDn5rptB7Is2F-GUVCXz3FQKsxeWhGIC7EMTT1rGG41TsHKb0QWpSyaXcZoBa86BwA2VL3iRm1QsHXrzRPARnUbXvMqJwkdWBSrOTbaJEUusepsLdSd0kX1MxPpqSTBCy7Bv54PCtdz9zZf9xFiAhTTIei1nWODvduHOL8MRHxhJKKs3I9ioR0fpnHTib85Jt6yKJQUSZxDyJ-HC_E1XDCZL-XJ1YEcSSeDsF8G-0IUoiujN9Xw5HDpfjl2ulF3JC46WG4TQW-FE8kiInCAqG_bkdYQlkbEfE-eeJtZ8O2wryywH2Tre4fmTs9l3nDwUxpDFavvyyRhFcIz_gItat9bjouKgWwKbUthS7nXQiCWaB5toV5k1a96xexhBsknWzePnOsp6KE8t2qiNwuE_Fyf7wc7hPvJ9c4eA-XamGU-EynFCPZQb14XoVdizlBb-__wRRYpu6dOrJlC8tR0Yg_Hz35C2sX4RS93wmCi3GYjRhfz7oeTk-C0O4qqFRqD-YFeLkxQr9ybSbuVm0q_XKUxmz7luVgL3O7M2l3R3bGZixojxurQgbbMxT8MYGA-x4QU3N-yaYG-zISuT-oZeEzWNPm8POEYrCHxkrVA9a26NQ0jv3A9x_dmoAEleH5SHkCid7oNK_HEtnoiJETbDhqaZVV4zBOShtgXtSBopcBYZyQHcYdJhW6lLNU2ZfjLg7pcGxHo60PhOCoO_ufkhO8MMbSQDWwaRIBTLRm0y9ARfEj709jvD8zGA0j8oHapw7VW6jayEOfmoT60O_UjpmG2C2dngCYr_i7-TtUB9y7fVPuXf1KDJLMXhiu1lrtOKQw5pjB1VOV4DlnvMhsULHh6EMrOj6bx7Fays8dlzzgaa5NRqLFMWbV6XhkD6ypaamcytq9-vIZt34lWEkQ**"/>
<input type="hidden" name="redirectURL" value="https://<hostname>/otcs/llisapi.dll?func=search&dspRegion1=OTDataID&dspRegion2=OTName&dspRegion3=OTDataSize&boolean1=and&lookFor1=complexquery&where1=OTLocation:<rootNodeId>&outputformat=xml"/>
<input type="hidden" name="func" value="otdsintegration.redirect"/>
<input type="hidden" name="NextURL" value="https://<hostname>/otcs/llisapi.dll?func=search&dspRegion1=OTDataID&dspRegion2=OTName&dspRegion3=OTDataSize&boolean1=and&lookFor1=complexquery&where1=OTLocation:<rootNodeId>&outputformat=xml"/>
</div>
<noscript>
<div><input type="submit" value="Continue"></div>
</noscript>
</form>
</body>
</html>
Any help would be much appreciated!
Thanks!