Download Attachment using Sales force .NET mobile sdk - c#

I am using Sales force Mobile SDK for .NET for my Universal Windows App
https://developer.salesforce.com/blogs/engineering/2015/04/salesforce-mobile-sdk-windows-ready-microsoft-developers.html
I am trying to download Attachment using following code
var restRequest = new RestRequest(Windows.Web.Http.HttpMethod.Get, AccountManager.GetAccount().InstanceUrl + "/services/data/v31.0/sobjects/Attachment/00S28000000FlXoEOK/Body");
var client = SDKManager.GlobalClientManager.GetRestClient() ??
new RestClient(AccountManager.GetAccount().InstanceUrl);
var response = await client.SendAsync(restRequest);
I am getting an unknown error with no error specification.
Any help highly appreciated.
Stack trace
at Salesforce.SDK.Rest.RestClient.d__b.MoveNext()
--- End of stack trace from previous location where exception was
thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at Salesforce.SDK.Rest.RestClient.d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at
Sample.ViewModel.MasterViewModel.d__3c.MoveNext()

Related

How do you tell dot net Graph SDK to use a custom proxy?

I am having problems getting the dotnet graph sdk to use my proxy settings as expected. I have tried setting the proxy when initializing the HttpClient with the GraphClientFactory but still seem to get the exception I am showing below. These same settings are being passed to the ConfidentialClientApplicationBuilder and is being used to succsesfully request the authentication token. It is also communicating to internal application API's through the same proxy settings with no problems. Can someone please help point me in the right direction? I am using the most recent version of the Graph SDK 4.36.0.0
public async Task Initialize(WebProxy webProxy)
{
var httpClientFactory = new GraphIntegrationHttpClientFactory(webProxy);
IConfidentialClientApplication daemonClient;
//Creates a daemon service.
daemonClient = ConfidentialClientApplicationBuilder.Create(_clientId)
.WithAuthority(string.Format(Constants.AuthorityFormat, _tenantId))
.WithClientSecret(_clientSecret)
.WithHttpClientFactory(httpClientFactory)
.Build();
//Gets auth token.
AuthenticationResult authResult = await daemonClient.AcquireTokenForClient(new string[] { Constants.MsGraphScope })
.ExecuteAsync();
ClientCredentialProvider authProvider = new ClientCredentialProvider(daemonClient);
var handlers = GraphClientFactory.CreateDefaultHandlers(authProvider);
handlers.Add(new LoggingHandler(_logService));
var httpClient = GraphClientFactory.Create(handlers, proxy: webProxy);
httpClient.Timeout = TimeSpan.FromMinutes(5);
_graphServiceClient = new GraphServiceClient(httpClient);
}
Exception
Microsoft.Graph.ServiceException: Code: generalException
Message: An error occurred sending the request.
---> System.InvalidOperationException: When using a non-null Proxy, the WindowsProxyUsePolicy property must be set to WindowsProxyUsePolicy.UseCustomProxy.
at Application.Common.Graph.Handlers.LoggingHandler.<SendAsync>d__2.MoveNext() in C:\Users\DamienOstler\Documents\GitHub\Application\src\main\Application.Common.Graph\Handlers\LoggingHandler.cs:line 42
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Graph.RedirectHandler.<SendAsync>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Graph.RetryHandler.<SendAsync>d__9.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Graph.CompressionHandler.<SendAsync>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Graph.AuthenticationHandler.<SendAsync>d__16.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Graph.SimpleHttpProvider.<SendRequestAsync>d__13.MoveNext()
--- End of inner exception stack trace ---
at Microsoft.Graph.SimpleHttpProvider.<SendRequestAsync>d__13.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Graph.SimpleHttpProvider.<SendAsync>d__10.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Graph.BaseRequest.<SendRequestAsync>d__40.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Graph.BaseRequest.<SendAsync>d__34`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Graph.UserRequest.<GetAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Application.Common.Graph.OneDriveIntegration.<GetUsers>d__10.MoveNext() in C:\Users\DamienOstler\Documents\GitHub\Application\src\main\Application.Common.Graph\OneDriveIntegration.cs:line 144
I have found a way to get around this problem, by passing a customer HttpClientHandler with all the information set as the finalhandler parameter for the GraphClientFactory Create method. I have opened a new issue on the github page about passing the proxy not working properly.

Certenroll on Azure - Generating self signed certificates

I have built a creation self-signing certificates using Certenroll (CERTENROLLLib). All works locally but as soon as I deploy it to Azure I get either:
Server API error: Message:
CertEnroll::CX509Enrollment::_CreateRequest: Access is denied.
0x80070005 (WIN32: 5 ERROR_ACCESS_DENIED), StackTrace: at
CERTENROLLLib.IX509Enrollment2.CreateRequest(EncodingType Encoding)
at
Foo.Api.Core.Providers.CertificateProvider.GenerateBase64EncodedPfx(String
subjectName, Int32 certificateValidityInYears, String password) at
Foo.Api.Core.Services.CertificateService.d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at
Foo.ServerApi.Services.DocumentSigningService.d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at
Foo.ServerApi.Services.DocumentSigningService.d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at
System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at
Foo.ServerApi.Controllers.DocumentController.<>c__DisplayClass10_1.<b__5>d.MoveNext()
if using:
var cert = new CX509CertificateRequestCertificate();
cert.InitializeFromPrivateKey(X509CertificateEnrollmentContext.ContextMachine, privateKey, "");
or
Server API error: Message:
CertEnroll::CX509CertificateRequestCertificate::InitializeFromPrivateKey:
The parameter is incorrect. 0x80070057 (WIN32: 87
ERROR_INVALID_PARAMETER), StackTrace: at
CERTENROLLLib.IX509CertificateRequestCertificate2.InitializeFromPrivateKey(X509CertificateEnrollmentContext
Context, IX509PrivateKey pPrivateKey, String strTemplateName) at
Foo.Api.Core.Providers.CertificateProvider.GenerateBase64EncodedPfx(String
subjectName, Int32 certificateValidityInYears, String password) at
Foo.Api.Core.Services.CertificateService.d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at
Foo.ServerApi.Services.DocumentSigningService.d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at
Foo.ServerApi.Services.DocumentSigningService.d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at
System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at
Foo.ServerApi.Controllers.DocumentController.<>c__DisplayClass10_1.<b__5>d.MoveNext()
if using:
var cert = new CX509CertificateRequestCertificate();
cert.InitializeFromPrivateKey(X509CertificateEnrollmentContext.ContextUser, privateKey, "");
Is there any way how to overcome this issue with Certenroll on Azure?
Edit: final error that lead me to the correct path.
Server API error: Message: CertEnroll::CX509PrivateKey::Create: The
system cannot find the file specified. 0x80070002 (WIN32: 2
ERROR_FILE_NOT_FOUND), StackTrace: at
CERTENROLLLib.IX509PrivateKey2.Create() at
Foo.Api.Core.Providers.CertificateProvider.GenerateBase64EncodedPfx(String
subjectName, Int32 certificateValidityInYears, String password) at
Foo.Api.Core.Services.CertificateService.d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at
Foo.ServerApi.Services.DocumentSigningService.d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at
Foo.ServerApi.Services.DocumentSigningService.d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at
System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at
Foo.ServerApi.Controllers.DocumentController.<>c__DisplayClass10_1.<b__5>d.MoveNext()
use X509CertificateEnrollmentContext.ContextUser in InitializeFromPrivateKey
when creating private key setting privateKey.MachineContext = false;
on Azure add a new Application Setting
WEBSITE_LOAD_USER_PROFILE = 1
that made it work for me

Random Messages Not Being Handled in Rebus

I have an odd issue with my implementation of Rebus which has been working for the past couple of years without any issue, and I am trying to figure out the scope of the problem and where to focus my troubleshooting effort. A little context:
We have been running version 0.99.66
Moved to version 3.1.5 last week, then saw the issues appear
Rolled back to 0.99.66, issues continue
Using MSMQ for the transport
Running Windows Server 2016
Identical code running on other server instances without issue
So, we are experiencing seemingly random instances where messages are failing, ending up in the error queue with a Rebus error saying that the message could not be dispatched to any handlers. This could happen once, but then when an identical message type comes through the next time, it gets handled correctly.
Here is a snippet of the code in question:
public class ProcessManagerService
{
public ProcessManagerService()
{
...
BusAdapter = new BuiltinHandlerActivator();
BusAdapter.Handle<FileEventMessage>(async msg => await StartProcess(msg));
BusAdapter.Handle<ProcessRequest>(async msg => await StartProcess(msg));
Bus = Configure.With(BusAdapter)
.Logging(l => l.ColoredConsole(LogLevel.Error))
.Transport(t => t.UseMsmq(ConfigurationManager.AppSettings["Queue"]))
.Start();
}
...
public async Task StartProcess(FileEventMessage msg)
{
var svc = new StepManager() { FileEvent = msg.FileEvent };
await svc.Run();
}
public async Task StartProcess(ProcessRequest msg)
{
var svc = new StepManager();
await svc.Run(msg);
}
}
And here is an example of the exception that is thrown:
5 unhandled exceptions: 12/18/2018 7:53:00 AM -06:00:
Rebus.Exceptions.RebusApplicationException: Message with ID
c72a8b6d-e31c-4a88-937e-612bf1db8b11 and type
ClearStone.Messages.Monitoring.File.FileEventMessage,
ClearStone.Messages could not be dispatched to any handlers at
Rebus.Pipeline.Receive.DispatchIncomingMessageStep.d__1.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at Rebus.Sagas.LoadSagaDataStep.d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at
Rebus.Pipeline.Receive.ActivateHandlersStep.d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at
Rebus.Pipeline.Receive.DeserializeIncomingMessageStep.d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at
Rebus.Pipeline.Receive.HandleDeferredMessagesStep.d__12.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at
Rebus.Retry.Simple.SimpleRetryStrategyStep.d__8.MoveNext()
UPDATE: Here is a more detailed stack trace after wiring in Rebus source:
5 unhandled exceptions: 12/20/2018 9:39:05 AM -06:00: Rebus.Exceptions.RebusApplicationException: Message with ID 84c3605a-41de-4300-9596-97e7288d2bcb and type ClearStone.Messages.Monitoring.File.FileEventMessage, ClearStone.Messages could not be dispatched to any handlers
at Rebus.Pipeline.Receive.DispatchIncomingMessageStep.d__1.MoveNext() in C:\Temp\rebus_0_99_66_archive\Rebus\Pipeline\Receive\DispatchIncomingMessageStep.cs:line 61
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at Rebus.Sagas.LoadSagaDataStep.d__7.MoveNext() in C:\Temp\rebus_0_99_66_archive\Rebus\Sagas\LoadSagaDataStep.cs:line 77
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at Rebus.Pipeline.Receive.ActivateHandlersStep.d__3.MoveNext() in C:\Temp\rebus_0_99_66_archive\Rebus\Pipeline\Receive\ActivateHandlersStep.cs:line 48
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at Rebus.Pipeline.Receive.DeserializeIncomingMessageStep.d__2.MoveNext() in C:\Temp\rebus_0_99_66_archive\Rebus\Pipeline\Receive\DeserializeIncomingMessageStep.cs:line 36
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at Rebus.Pipeline.Receive.HandleDeferredMessagesStep.d__12.MoveNext() in C:\Temp\rebus_0_99_66_archive\Rebus\Pipeline\Receive\HandleDeferredMessagesStep.cs:line 114
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at Rebus.Retry.Simple.SimpleRetryStrategyStep.d__8.MoveNext() in C:\Temp\rebus_0_99_66_archive\Rebus\Retry\Simple\SimpleRetryStrategyStep.cs:line 105
Assuming the obvious and that it is something in this particular server instance/enviornment, I am trying to figure out why Rebus is behaving this way, and what in my environment may be causing this. Any direction as to where to start looking would be greatly appreciated!
Sounds pretty weird :) when people have this problem, it's almost always because they have somehow set up multiple Rebus instances to consume messages off of the same queue.
In some rare cases, it's because .Start() is called on the bus before handlers are added to the container/built-in handler activator, but that doesn't seem to be the problem in your case.
Can you tell me more about your setup? If it's about as simple as what you're showing above, maybe you can reproduce it in a separate application?

Magento.RestApi behaves different when loaded dynamically from DLL

I am using Magento.RestApi in a larger system, where I load the code dynamically from a DLL.
When I use the below code in a stand-alone project, it works fine:
private async void dostuff() {
var client = new MagentoApi()
.Initialize("<url>", "key", "secret")
.AuthenticateAdmin("user", "pass");
var response = await client.GetProductBySku("sku");
// The response contains the result or errors
if (!response.HasErrors) {
var product = response.Result;
... do stuff with the result ...
}
}
But, when loaded in the larger project, I get "The request was not successfully completed.", also when trying to catch the error to find the InnerException or the stack trace, the debugger doesn't seem to work anymore. Printing out the stack trace gives me:
at Magento.RestApi.MagentoApi.<HandleResponse>d__35`1.MoveNext() in C:\Users\bart\Documents\Visual Studio 2015\Projects\SapphireMagentoDriver\SapphireMagentoDriver\MagentoApi.cs:line 445
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at Magento.RestApi.MagentoApi.<Execute>d__34`1.MoveNext() in C:\Users\bart\Documents\Visual Studio 2015\Projects\SapphireMagentoDriver\SapphireMagentoDriver\MagentoApi.cs:line 410
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at Magento.RestApi.MagentoApi.<GetProductBySku>d__45.MoveNext() in C:\Users\bart\Documents\Visual Studio 2015\Projects\SapphireMagentoDriver\SapphireMagentoDriver\MagentoApi.cs:line 708
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at Magento.RestApi.SapphireMagentoDriver.<DoDownloadArticles>d__6.MoveNext() in C:\Users\bart\Documents\Visual Studio 2015\Projects\SapphireMagentoDriver\SapphireMagentoDriver\DriverInterface.cs:line 103
I had to compile the Magento.RestApi from source, as the NuGet package uses a different NewtonSoft.Json package than my large project. This works fine in the stand alone version.

Web API runs on Visual Studio but not when deployed on IIS

I'm doing some research on integration with CIDR/Aadhaar systems (Indian system for unique identification of individuals). I chose the Nuget package which was the only available option that I found. The package data is present here.
I developed a console application to test the code and I got successful results for the test data provided by CIDR. I then proceeded to develop a Web API 2 for the same and it worked perfectly the same way when I ran the project from Visual Studio (which uses IIS Express). But after deploying it to IIS, I get the following exception (I had downloaded the source of the package from Nuget to pinpoint the cause):
[2017-02-07 11:52:44:434] http://localhost/AadhaarAPI/api/Aadhaar : Type : System.AggregateException
[2017-02-07 11:52:44:434] http://localhost/AadhaarAPI/api/Aadhaar : Error : One or more errors occurred.
[2017-02-07 11:52:44:520] http://localhost/AadhaarAPI/api/Aadhaar : Stacktrace :
at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
at Uidai.Aadhaar.Agency.ApiClient`2.<GetResponseXmlAsync>d__25.MoveNext() in D:\Sujeet\VSProjects\AadhaarAPI\Uidai.Aadhaar\Agency\ApiClient.cs:line 138
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at Uidai.Aadhaar.Agency.ApiClient`2.<GetResponseAsync>d__22.MoveNext() in D:\Sujeet\VSProjects\AadhaarAPI\Uidai.Aadhaar\Agency\ApiClient.cs:line 94
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at Uidai.Aadhaar.Agency.ApiClient`2.<GetResponseAsync>d__21.MoveNext() in D:\Sujeet\VSProjects\AadhaarAPI\Uidai.Aadhaar\Agency\ApiClient.cs:line 78
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at AadhaarAPI.Controllers.AadhaarController.<AuthenticateAsync>d__13.MoveNext() in D:\Sujeet\VSProjects\AadhaarAPI\AadhaarAPI\Controllers\AadhaarController.cs:line 119
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at AadhaarAPI.Controllers.AadhaarController.CheckIfAadhaarIsValid(PersonalInfo personalInfo) in D:\Sujeet\VSProjects\AadhaarAPI\AadhaarAPI\Controllers\AadhaarController.cs:line 53
From my understanding so far, the await/async calls are the ones causing the error. The code snippet for the async call is as follows:
var apiClient = new AuthClient
{
AgencyInfo = APIConfiguration.AgencyInfo,
Request = new AuthRequest(deviceContext) { Signer = Signer },
Response = new AuthResponse { Verifier = Verifier }
};
await apiClient.GetResponseAsync(); // This is where the call throws an error
var response = string.IsNullOrEmpty(apiClient.Response.ErrorCode)
? $"{apiClient.Response.IsAuthentic}"
: $"{apiClient.Response.ErrorCode}";
Can someone please help me with understanding this error?
Please let me know if any other information is needed. I'm using Visual Studio 2017 RC for my development, if that matters.
Disclaimer: The code snippet is also provided by the package developer. I don't take credit for any of this development.
EDIT:
As per the comments, the details of the AggregateException are as follows:

Categories

Resources