You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have create console application using .net core 3.
Code
String API_KEY = "my user name";
String API_SECRET = "my password";
Boolean HMAC = false;
MessageMediaMessagesClient client = new MessageMediaMessagesClient(API_KEY, API_SECRET, HMAC);
MessagesController messages = client.Messages;
SendMessagesRequest body = new SendMessagesRequest();
body.Messages = new List<Message>();
Message body_messages_0 = new Message();
body_messages_0.Content = "Test SMS from Tarun";
body_messages_0.DestinationNumber = "+16233266836";
body.Messages.Add(body_messages_0);
try
{
MessageMedia.Messages.Models.SendMessagesResponse result = messages.SendMessagesAsync(body).Result;
Console.WriteLine(result);
}
catch (APIException e)
{
Console.WriteLine(e.Message + e.ResponseCode + e.HttpContext.ToString());
};
Getting below error
System.AggregateException HResult=0x80131500 Message=One or more errors occurred. (HTTP Response Not OK) Source=System.Private.CoreLib StackTrace: at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) at System.Threading.Tasks.Task1.GetResultCore(Boolean waitCompletionNotification)
at System.Threading.Tasks.Task`1.get_Result()
at ConsoleApp4.Program.Main(String[] args) in C:\Users\Tarun\source\repos\ConsoleApp4\ConsoleApp4\Program.cs:line 45
This exception was originally thrown at this call stack:
[External Code]
Inner Exception 1:
APIException: HTTP Response Not OK
`
The text was updated successfully, but these errors were encountered:
@jadav1982 and @maqsoodahmad, while I'm not involved in the development of this, I might be able to assist / advise. If either of you are still having issues try replacing the catch block with:
catch (AggregateException e)
{
foreach (Exception exception in e.InnerExceptions)
{
if (exception.GetType() == typeof(APIException))
Console.WriteLine(String.Format("{0}; {1};",(exception as APIException).Message, (exception as APIException).ResponseCode));
}
};
The example provided in the ReadMe isn't correct and results in an Unhandled Exception (Tasks throw AggregateExceptions) and you lose the content of the APIException which should have the Response Code in it.
Hello,
I have create console application using .net core 3.
Code
Getting below error
System.AggregateException HResult=0x80131500 Message=One or more errors occurred. (HTTP Response Not OK) 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 ConsoleApp4.Program.Main(String[] args) in C:\Users\Tarun\source\repos\ConsoleApp4\ConsoleApp4\Program.cs:line 45
This exception was originally thrown at this call stack:
[External Code]
Inner Exception 1:
APIException: HTTP Response Not OK
`
The text was updated successfully, but these errors were encountered: