401 when authenticating with clickatel sms api - c#

I am simply trying to send an sms using the clickatel API.
I have used the helper library found here: https://github.com/clickatell/clickatell-csharp
var apiClient = new RestClient(new RESTCredentials(ApiKey));
var result = apiClient.Authenticate();
Debug.Write("_apiClient.Authenticate() = " + result.Result);
and I get the following:
"Error occured during Clickatell Authenticate. Details: The remote server returned an error: (401) Unauthorized."
I have checked the api key several times, I have even regenerated a new on on their portal.
Am I missing something?

I see you're using the old Clickatell Csharp library that was written for the old endpoint.
You will need to use the new script which can be found at https://github.com/clickatell/Clickatell-Csharp-Platform
Hopefully this will resolve the issue.

Related

Twilio "click to call" C#

Here's my scenario - a user enters his phone number and the number of the person he wants to call.
Via c# Twilio calls the user number then connects to the person he wants to call. I then record the conversation.
I can get it all working and recording for a single phone number.
However, when trying to connect to a second number (the first number does ring, but I get the standard Twilio "application error"), I get the following 502 error:
Twilio was unable to fetch content from: https://xxx.xxx.net/Call/Connect?recipientNumber={number}
Error: Error reading response: Response does not contain content type
Account SID: xxxxxxxxxxxxxxxxxxxxxxxx
SID: xxxxxxxxxxxxxxxxxxxxxx
Request ID: xxxxxxxxxxxxxxxxxxxxx
Remote Host: xxx.xxx.net
Request Method: POST
Request URI: https://xxx.xxx.net/Call/Connect?recipientNumber={number}
SSL Version: TLSv1.2
This stems from basic code:
var response = new VoiceResponse();
response.Say("We are about to connect you.").Dial(recipientNumber).Hangup();
return TwiML(response);
Can anyone advise on where I'm going wrong or what I'm missing?
Turns out it was a conflict of versioning and/or DLL's - removed nuget Twilio package and manually added Twilio DLL's. Problem solved!!!

Got error when access https URL using HttpClient

i'm using Visual Studio to build Android application. I'm using REST API to communicate the app with the server, and later i got this error
System.Net.Http.HttpRequestException: An error occurred while sending the request
this is my codes
var client = new HttpClient();
client.DefaultRequestHeaders.Add(defaultData.headerName, defaultData.headerData);
var json = await client.GetStringAsync("https://example.com/api");
var items = JsonConvert.DeserializeObject<ArdilesmetroClass>(json);
This problem occurs when i try to accessing https url and it works fine when accessing http. What i need to add in my codes?
Done, i have the answer.Go to your Project Properties->Android Options-> Click Advanced. You need to change SSL/TLS implementation to
Native TLS 1.2+

Using GET request causes bot dialog to fail

I've connected my bot application to the direct line API which is published with Azure. I am currently testing the application with a command line client application, the bot framework emulator, and the dev.botframework.com homepage for my bot.
Everything works correctly until I attempt to submit a GET request to a REST API. I've tested the GET API request in a separate project and it works correctly and the GET request worked prior to implementing the direct line channel. Is there anything I need to be aware of when making http requests with the direct line on the bot side?
Code in question
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", headerParam);
var response = client.GetAsync(new Uri("someUrl.com/api/v1/auth")).Result;
string content = response.Content.ReadAsStringAsync().Result;
var jo = JObject.Parse(content);
this.token = jo["Result"]["Token"].ToString();
}
await context.PostAsync(this.token);
the line that actually causes the failure is
var response = client.GetAsync(new Uri("someUrl.com/api/v1/auth")).Result;
Also is there an easier way to debug a project when it's published to azure and running direct line API?
System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: An attempt was made to access a socket in a way forbidden by its access permissions ipaddress
I have tried to invoke my custom REST API within my bot application back-end, then I could leverage Remote debugging web apps to retrieve the result from my bot application hosted on Azure web app as follows:
After searching for the related issue, I found that there be limitation for the number of sockets of your current app service plan when creating the new outgoing connections. You could try to scale up your App Service plan or create a new web app to isolate this issue. For more details, you could refer to this similar issue and this blog.

Google Maps For Work API in ASP.NET

Hello I need to know how to call google maps API for work form inside a an ASP.NET C# code
namely the Geocoding API
I tried using this
string query = "30.0013759" + "," + "31.236013";
string address = "";
XmlDocument geocoderXmlDoc = new XmlDocument();
geocoderXmlDoc.Load("http://maps.google.com/maps/api/geocode/xml?client=gme-myclientid&latlng=" + query + "&sensor=false");
but it responded with 403 forbidden to me
can anybody help?
Read this documentation regarding 403 error for Google Maps Geocode. It says:
Why am I receiving a HTTP 403 Forbidden response to my Maps API web service requests?
An HTTP 403 response indicates a permission issue, likely because the signature could not be verified for this request. This could be because:
a. A signature has been specified but is incorrect for this request.
b. The request specifies a Google Maps API for Work client id but does not specify a signature, and the web service being called requires that all requests made using a client id include a valid signature.
c. A signature has been specified but the associated Google Maps API for Work client ID has not been specified.

Getting error :(The remote server returned an error: (401) Unauthorized) when trying to call http://twitter.com/account/verify_credentials.xml

I'm following this Url to authenticate user to my website using twitter login. I'm able to get the access token but when im calling below code
url = "http://twitter.com/account/verify_credentials.json";
xml = oAuth.oAuthWebRequest(oAuthTwitter.Method.GET, url, String.Empty);
im getting 401 unauthorized error. Can anyone guide me what can be the problem
I am not an expert on the Twitter API's but here is a post in the dev.twitter forums that seem to be very similar to what you are experiencing.
https://dev.twitter.com/discussions/1750
Your URL is wrong. It is https://api.twitter.com/1.1/account/verify_credentials.json (or https://api.twitter.com/1/account/verify_credentials.json depending of the version of the Twitter API (1 or 1.1) you use). Twitter recently removed endpoints whose domain name is not api.twitter.com and endpoints without the version of the API : https://dev.twitter.com/discussions/10803
If it is still wrong, ensure that you authorize your requests correctly : https://dev.twitter.com/docs/auth/authorizing-request
NB : Twitter will send you back JSON datas, not XML. You should write "json = oAuth.oAuthWebRequest(oAuthTwitter.Method.GET, url, String.Empty);" instead of "xml = oAuth.oAuthWebRequest(oAuthTwitter.Method.GET, url, String.Empty);" in your code. If you want XML datas, use this URL : https://api.twitter.com/1/account/verify_credentials.xml. But this last will not work after March 2013.

Categories