Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Trapping web return errors
Message
De
18/12/2014 12:11:59
 
 
À
18/12/2014 12:03:00
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
C# 5.0
OS:
Windows Server 2008
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01612403
Message ID:
01612405
Vues:
41
>When I call a webservice and it returns an error how can I trap the full error message
>
>I've got this code
>
>HttpWebResponse response = null;
> HttpWebRequest request = (HttpWebRequest)WebRequest.Create(profileAPIURL);
> request.Headers.Add("Authorization", oAuth);
> try
> {
> response = (HttpWebResponse)request.GetResponse();
> }
> catch (Exception ex)
> {
> Console.WriteLine("Exception Occured:" + ex.Message);
> }
>
>but the catch just gives me a server error like "The remote server returned an error: (400) Bad Request." and I want to know the reason its a bad request.
>
>Thanks
>
>Nick

400 should mean that your request was badly/wrongly formed

You could just use Fiddler - that will show you the exact request that was sent and full response received from the server.

You can also use fiddler to tinker with the request parameters/headers until you get a valid response.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform