Yani benim web uygulaması içine http://www.html2pdfrocket.com/convert-csharp-to-pdf gelen kısa kod parçacığınıNeden "Uzak sunucu bir hata verdi: (401) Yetkisiz." bu kod snippet'inden mi?
public ActionResult Run()
{
string apiKey = "ABCD-1234";
string value = "http://www.google.com"; // a url starting with http or an HTML string
using (var client = new WebClient())
{
// Build the conversion options
NameValueCollection options = new NameValueCollection();
options.Add("apikey", apiKey);
options.Add("value", value);
// Call the API convert to a PDF
MemoryStream ms = new MemoryStream(client.UploadValues("http://api.html2pdfrocket.com/pdf", options));
// Make the file a downloadable attachment - comment this out to show it directly inside
HttpContext.Response.AddHeader("content-disposition", "attachment; filename=myfilename.pdf");
// Return the file as a PDF
return new FileStreamResult(ms, "application/pdf");
}
}
yapıştırılan-kopyalayıp
[WebException: The remote server returned an error: (401) Unauthorized.] System.Net.WebClient.UploadValues(Uri address, String method, NameValueCollection data) +490
System.Net.WebClient.UploadValues(String address, NameValueCollection data) +35 Survey.Controllers.AnswersController.Run() +163
lambda_method(Closure , ControllerBase , Object[]) +62
System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +14
Hiçbir için, client = UseDefaultCredentials = true;
ekleyerek çalıştı gibi bir yığın izleme ile 401 hatası alıyorum boşuna.
Denediğim başka fikirler var mı?
okumak? –
bu dokümanı okuyun https://html2pdfwebservice.com/documentation API Kimlik Doğrulama Bölümü'nde diyor. Henüz bir hesabınız yoksa, 14 günlük ücretsiz deneme sürümümüze kayıt olabilirsiniz. Web servisimize karşı kimlik doğrulaması yapmak için API anahtarınızı ve kullanıcı adınızı kullanmanız gerekir. Bunlar profil sayfanızda ve gösterge panosunda bulunabilir. – rashfmnb
Oh, paraya mı mal oluyor? Boşver. –