You must Sign In to post a response.
  • Category: .NET

    Error in my below code

    My requirement is i want to upload the pdf file and save in separate folder Upload file
    Second section is to call API (In that API auto bookmark code is available)
    Third section is to save autobookmark pdf in folder Upload file.

    i have writeen below code is as follows

    if (ModelState.IsValid)
    { //iterating through multiple file collection
    foreach (HttpPostedFileBase file in files)
    //Checking file is available to save.
    if (file != null)
    var InputFileName = Path.GetFileName(file.FileName);
    var ServerSavePath = Path.Combine(Server.MapPath("~/UploadedFiles/") + InputFileName);
    //Save file to server folder
    //assigning file uploaded status to ViewBag for showing message to user.
    ViewBag.UploadStatus = files.Count().ToString() + " files uploaded successfully.";

    var response = new HttpResponseMessage();
    using (HttpClient httpClient = new HttpClient())

    httpClient.BaseAddress = new Uri(;
    response = httpClient.PostAsync(@"api/job/GetTestPDF", new StringContent(string.Empty)).Result;

    var whatisThis = response.Content.ReadAsStringAsync().Result;
    return new FileContentResult(Convert.FromBase64String(response.Content.ReadAsStringAsync().Result), "application/pdf");

    return View();

    i have get below error in below line as follows

    httpClient.BaseAddress = new Uri(@;

    the best overload for uri does not have a parameter named https

    please let me know how to solve the above error
  • #770397
    Hi Rao,
    As I can see, you have missed the "" for Uri method.
    It should be like:

    httpClient.BaseAddress = new Uri(@"");

    Also there is another issue where you have api two times in your URL.
    Below using the API's better to go to the browser and type the same url and see what is the response. If there is any issue, it will give some error.
    I just types the correct url as:
    which gives me "Connection Success" as the response.
    So your code should be like:

    httpClient.BaseAddress = new Uri(@"");
    response = httpClient.PostAsync(@"api/job/GetTestPDF", new StringContent(string.Empty)).Result;

    Hope it will help.

    Pawan Awasthi(DNS MVM)
    +91 8123489140 (whatsApp), +60 14365 1476(Malaysia)

  • Sign In to post your comments