How to solve 500 internal server
Hi Iam working with some api that not working properly iam getting error like 500 internal serverhow to solve this
namespace ConsoleBonanzas
{
class Program
{
static void Main(string[] args)
{
string response = "";
string requesterCredentials = "\"requesterCredentials\": {\"bonanzleAuthToken\": \"mytoken\"},";
string itemSpecifics = "\"itemSpecifics\": [[\"condition\", \"used\"], [\"danger\", \"extreme\"]],";
string itemVariations = "\"variations\": [{\"nameValueList\": [{\"name\": \"Colour\", \"value\": \"Blue\"}, {\"name\": \"Style\", \"value\": \"Single\"}], \"quantity\": 3}, {\"nameValueList\": [{\"name\": \"Colour\", \"value\": \"Red\"}, {\"name\": \"Style\", \"value\": \"string\"}], \"quantity\": 1}],";
string pictureDetails = "\"pictureDetails\": {\"pictureURL\": [\"http://images.discountstarwarscostumes.com/products/9284/1-1/luke-skywalker-blue-ightsaber.jpg\", \"http://www.rankopedia.com/CandidatePix/29862.gif\"]},";
string itemDescription = "\"description\": \"An elegant weapon, for a more civilized age * SELLER NOT LIABLE FOR DISMEMBERMENT *\",";
string contentToPost = "addFixedPriceItemRequest={" + requesterCredentials + "\"itemId\": 208617, \"item\": {\"shippingType\": \"Free\"," + itemDescription + "\"title\": \"Lightsaber\", \"price\": 42, \"quantity\": 3," + itemVariations + "\"primaryCategory\": {\"categoryId\": \"163128\"}}";
response = makeRequest(contentToPost);
Console.Write("response is" + response);
Console.Read();
}
private static string makeRequest(string contentToPost)
{
try
{
string Api_url = "https://api.bonanza.com/api_requests/secure_request";
//System.Net.WebRequest request = System.Net.WebRequest.Create(Api_url);
HttpWebRequest request = (HttpWebRequest)System.Net.WebRequest.Create(Api_url);
request.Headers.Add("X-BONANZLE-API-DEV-NAME", "mydevname");
request.Headers.Add("X-BONANZLE-API-CERT-NAME", "mycername");
// System.Net.ServicePointManager.ServerCertificateValidationCallback = new Net.Security.RemoteCertificateValidationCallback(CertificateValidationCallBack);
System.Net.ServicePointManager.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback(CertificateValidationCallBack);
byte[] contentBytes = System.Text.Encoding.UTF8.GetBytes(contentToPost);
request.Method = "POST";
request.AllowAutoRedirect = true;
request.ContentLength = contentBytes.Length;
System.IO.Stream requestStream = request.GetRequestStream();
requestStream.Write(contentBytes, 0, contentBytes.Length);
System.Console.WriteLine(requestStream);
//requestStream.Close()
System.Net.HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Console.Write("response...." + response);
// Read the response into a StreamReader
System.IO.StreamReader responseReader = new System.IO.StreamReader(response.GetResponseStream(), System.Text.Encoding.UTF8);
string strResponse = responseReader.ReadToEnd();
//System.Console.WriteLine(strResponse);
//System.Console.ReadLine();
Console.Write(strResponse);
Console.Read();
return strResponse;
}
catch (Exception ex)
{
System.Console.WriteLine("Failed to call Bonanza with content " + contentToPost + ", " + ex.Message );
throw;
}
}
private static bool CertificateValidationCallBack(object sender, System.Security.Cryptography.X509Certificates.X509Certificate certificate, System.Security.Cryptography.X509Certificates.X509Chain chain, System.Net.Security.SslPolicyErrors sslPolicyErrors)
{
return true;
}
}
}