I'm trying to use the Indicium OData API via a .NET Core 3.0 console application. I receive an exception on inserting records, while the record is inserted in the database. I have no clue why. I'm not sure if this is an issue in the Indicium OData API or the .NET nuget package.
For example I want to add a ‘server’ to the IAM database. By using a generated piece of code (see https://docs.microsoft.com/nl-nl/odata/client/basic-crud-operations) this is quite easy to set up;
With the following code you retrieve the ‘server’ table and insert a new record in to it:
using SQLSERVER_IAM;
using System;
using System.Net;
namespace IndiciumTest
{
class Program
{
static void Main(stringi] args)
{
var uri = new Uri("http://server/indicium/iam/iam");
var container = new Container(uri);
container.Credentials = new NetworkCredential("userName", "password");
// iterating servers works.
var servers = container.Server.ExecuteAsync().Result;
foreach(var s in servers)
{
Console.WriteLine(s.Server_name);
}
var server = new Server
{
Server_address = "localhost",
Server_name = "localhost",
Rdbms_type = 0
};
container.AddToServer(server);
// saving works, but gives an exception
var result = container.SaveChangesAsync().Result;
}
}
}
On the line ‘var result = container.Save...’ it gives the following exception:
System.AggregateException
HResult=0x80131500
Message=One or more errors occurred. (An error occurred while processing this request.)
Source=System.Private.CoreLib
StackTrace:
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
at System.Threading.Tasks.Task`1.get_Result()
at IndiciumTest.Program.Main(Stringr] args) in C:\Users\user\source\repos\IndiciumTest\IndiciumTest\Program.cs:line 33
Inner Exception 1:
InvalidOperationException: An error occurred while processing this request.
Inner Exception 2:
InvalidOperationException: The 'Location' header value specified in the response must be an absolute URI.
The server ‘localhost’ is in this case added to the iam database, but due to the fact it gives an exception I'd almost assume it failed. Any ideas on this?