System.net.webexception in system.dll - c#

I have followed this tutorial to update a powerbi dashboard here.
I have copied all the code from Microsoft's website. Of course I have supplied my own clientId.
The console application successfully creates a dataset, but does not add rows to the table.
It fails here:
var response = (HttpWebResponse)request.GetResponse();
An unhandled exception of type 'System.Net.WebException' occurred in System.dll
Additional information: The remote server returned an error: (404) Not Found.

The URL you are querying is wrong or no longer exists. Check the documentation for the APIs you are querying to make sure you are properly constructing the URL.
Start here for PowerBI APIs: https://msdn.microsoft.com/library/dn877544.aspx

Related

Issue with getting Access token using forge DA

I am trying to get an access token using Forge DA using the code below. But it throws the following exception:
An exception of type 'Autodesk.Forge.Client.ApiException' occurred in mscorlib.dll but was not handled in user code. Additional information: Error calling Authenticate: The underlying connection was closed: An unexpected error occurred on a send.
Here is my code:
TwoLeggedApi oAuth = new TwoLeggedApi();
dynamic token = await oAuth.AuthenticateAsync(
txtClientId.Text,
txtClientSecret.Text,
oAuthConstants.CLIENT_CREDENTIALS ,
new Scope[] { Scope.BucketRead, Scope.BucketCreate, Scope.DataRead, Scope.DataWrite });
Since the error is calling out connection make sure your system can reach our service from your network (check proxy, firewall etc, can you reach our other endpoints?) and it supports TLS 1.2 - see here
I recommend that you use the Design Automation SDK here. This one allows you to access the new V3 API while the one I presume you are using can only access the now deprecated V2 API.
Here's a sample that uses this SDK.

'System.AggregateException' when attempting to connect to my Common Data Service web api

Here is my code:
string url = "https://myOrg.api.crm.dynamics.com";
string apiVersion = "9.1";
string webApiUrl = $"{url}/api/data/v{apiVersion}/";
var authParameters = AuthenticationParameters.CreateFromResourceUrlAsync(new Uri(webApiUrl)).Result;
My last line of code is failing with:
The ouput is:
MyAPITest.vshost.exe Error: 0 : 11/05/2019 19:20:17: - AuthenticationParameters: System.ArgumentException: Unauthorized Http Status Code (401) was expected in the response
Parameter name: response
Exception thrown: 'System.AggregateException' in mscorlib.dll
The program '[5556] MyAPITest.vshost.exe' has exited with code -1 (0xffffffff).
For reference, I am attempting to use the Quick Start Guide to connect to the Common Data Service.
EDIT:
In looking at the details I am seeing:
Error
The underlying connection was closed: An unexpected error occured on a send.
More detail beneath that error:
Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
AuthenticationParameters: System.ArgumentException: Unauthorized Http Status Code (401) was expected in the response
The error is typically because it's lacking valid authentication credentials and the request has not been applied for the target resource.
Also if you don't know, the AuthenticationParameters.CreateFromResourceUrlAsync API is obsolete, read more there.
With this in mind, I would look into using AuthenticationParameters.CreateFromUrlAsync(Uri) Method in which should be used. It sends a GET request to the url provided with no Authenticate header. If a 401 Unauthorized is received, this helper will parse the WWW-Authenticate header to retrieve the authority and resource.
Here was the problem, found in the guide:
I am running VS 2015. Once I unchecked this, it worked perfectly.

Error Code 429 when attempting to download page's HTML

I'm not really a developer and only just coded during university and for fun. I'm currently working on a small project involved in web scraping with c# and I can't seem to download the HTML code from the website I want, see code below.
private asynch void GetHTML1()
{
//Crownbet
string crownbet_url = "https://crownbet.com.au/sports-betting/australian-rules/afl/afl-matches/";
HttpClient crownbet_httpClient = new HttpClient();
var crownbet_html = await crownbet_httpClient.GetStringAsync(crownbet_url).Result;
HtmlAgilityPack.HtmlDocument crownbet_htmlDocument = new HtmlAgilityPack.HtmlDocument();
crownbet_htmlDocument.LoadHtml(crownbet_html);
}
When I run this code I get the following error.
Exception thrown:
'System.Net.WebException' in System.dll An unhandled exception of type
'System.Net.WebException' occurred in System.dll The remote server
returned an error: (429) Calm down.
I'm not too sure what's wrong here because I've used this method to grab HTML code from other websites and it seems to work fine. Status 429 is usually given when you send too many requests to a website right?

How to Remove 'System.Net.WebException' occurred in System.dll where server returned an error code of (500)

I am using webclient to upload my files to server via Rest Service. I am checking my code by debugging it on a local host what I found is my server is successfully receiving all these files but at client end where I have a code for sending file I am getting this exception.
An unhandled exception of type 'System.Net.WebException' occurred in System.dll
Additional information: The remote server returned an error: (500) Internal Server Error."
The code I am using is below:
var Filereqparam = new System.Collections.Specialized.NameValueCollection();
using (var lWebClient = new WebClient()) {
foreach (var file in data.file) {
Filereqparam.Add("FileName", file.FileName);
Filereqparam.Add("FileExtension", file.FileExtension);
Filereqparam.Add("FileData", file.FileData);
System.Diagnostics.Debug.WriteLine( Filereqparam);
var recvFiledata = lWebClient.UploadValues("http://localhost:56156/api/userfiles/getfiles", Filereqparam);
var respFileBody = Encoding.UTF8.GetString(recvFiledata);
}
}
I have set the time limit for client to unlimited, but still I am unable to resolve this issue. My question is why I am receiving this exception if my files are successfully sent to server?
Note: If anyone know a better way to upload the large files to server via rest service then please share your technique.

Getting LINQ to Firebird to work

I'm trying to generate an entity model from a Firebird database using the Entity Data Model Wizard, but it dies loading the data for the "Choose Your Database Objects" step with the error:
Microsoft Visual Studio
An error occurred while connecting to the
database. The database might be
unavailable. An exception of type
'System.Data.EntityCommandExecutionException'
occurred. The error message is: 'An
error occurred while executing the
command definition. See the inner
exception for details.
The inner exception caught was of type
'FirebirdSql.Data.FirebirdClient.FbException',
with this error message: 'Dynamic SQL
Error
SQL error code = -104
Token unknown - line 6, column 8
SELECT'.
The inner exception caught was of type
'FirebirdSql.Data.Common.IscException',
with this error message: 'Exception of
type
'FirebirdSql.Data.Common.IscException'
was thrown.'.'.
[ OK ]
I certainly believe it should work from this blog post on the ADO.Net team blog.
I'm able to browse tables and definitions using server explorer, so I think it's safe to discount connectivity/permissions issues, but I'm at a bit of a loss as to what else to check to get this working?
The blog post you speak about is beta version
the final release is on Jiri blog
or on Firebird
or here
According to the comment on this blog post, Firebird 1.5 is not support for LINQ to Firebird, even though it is supported version according to the Firebird website.

Categories

Resources