I am trying to call a REST API for IDM (Infor Document Manager) from .Net C#.
This works great against M3 & Grid API's, but for some reason, not working against the IDM Specific API for some reason.
Has anyone else encountered this issue?
Sample of code not working for IDM REST API's for some reason (I have highlighted the statement that it fails on - authentication issue) :
using System;
using System.Data.SqlClient;
using System.IO;
using System.Net;
using System.Text;
using Microsoft.SqlServer.Server;
</code></p>
<p><code>public partial class StoredProcedures
{
</code><code>[Microsoft.SqlServer.Server.SqlProcedure]
public static void GetImageIDM(
String serverInstance,
int IDM_Port,
String appInstance,
String IDMSection,
String IDM_ID)
{
</code><code>SqlPipe pipe_msg = SqlContext.Pipe;
try
{
</code><code>requestString = "<a href="https://myserver.mydomain.com:7443/infor/IDM/api/items/search?%24query=%2FCOSTING%5B%40OPTIVA_SYMBOL_ID%3D%22ITEMNUMBER%22%5D&%24offset=0&%24limit=1">">myserver.mydomain.com:7443/.../search</a>
</code></p>
<p style="padding-left:90px;"><code>HttpWebRequest request = (HttpWebRequest)WebRequest.Create(requestString);
</code></p>
<p style="padding-left:90px;"><code>request.Method = "GET";
request.ContentLength = 0;
request.Timeout = 3600;
</code></p>
<p style="padding-left:90px;"><code>request.ContentType = "application/xml; charset=UTF-8";
request.Accept = "application/json";
</code></p>
<p style="padding-left:90px;"><code>request.CookieContainer = cookies;
</code></p>
<p style="padding-left:90px;"><code>CredentialCache netCred = new CredentialCache();
netCred.Add(new Uri(requestString), "Basic", new NetworkCredential("myuser@mydomain.com", "MyPwd"));
request.Credentials = netCred;
pipe_msg.Send(request.RequestUri.ToString());
</code></p>
<p style="padding-left:90px;"><code>var httpResponse = (HttpWebResponse)request.GetResponse(); <span style="background-color:#ffff00;">//*** This is where it fails!!!***
pipe_msg.Send("httpResponse: " + httpResponse.ToString());
pipe_msg.Send("request.HaveResponse: " + request.HaveResponse.ToString());
</code></p>
<p style="padding-left:90px;"><code>string response;
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
</code><code>response = streamReader.ReadToEnd();
pipe_msg.Send("response: " + response.Substring(0, 3900));
</code><code>}
</code><code>}
catch (Exception ex)
{
</code><code>SqlContext.Pipe.Send("Error (GetImageIDM): " + ex.Message);
</code></p>
<p style="padding-left:60px;"><code>}
</code><code>}
}
René