I am trying to access LightSwitch oData using Basic authentication but continue to have issues.
The code is listed below:
var serviceCreds = new NetworkCredential("username", "password");
var cache = new CredentialCache();
var serviceUri = new Uri("https://hub.website.com/ApplicationData.svc/");
cache.Add(serviceUri, "Basic", serviceCreds);
var odataService = new ApplicationData(new Uri("https://hub.website.com/ApplicationData.svc/"));
odataService.Credentials = cache;
var localitmItems = odataService.mkgKeywords;
The error is:
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
at Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTATaskScriptingEngine.ExecuteScript()