none
HTTPClient in .net 3.5 RRS feed

All replies

  • The HttpClient is not available in .net 3.5. You have a few possibility upgrade a newer version of the .net framework or if you cant upgrade there are a few other classes you can use.

    The HttpRequest

    https://www.c-sharpcorner.com/Blogs/calling-web-api-using-httpwebrequest-in-c-sharp

    or the WebClient

    https://www.c-sharpcorner.com/blogs/consume-webapi-using-webclient-in-c-sharp

    Sunday, October 6, 2019 7:12 PM
  • Hi friend,

    Sorry for delay in reply.

    HttpClient Class applies to .NET Framework from 4.5 to 4.8. Also, WebAPI requires .NET 4 and you cannot use it on .NET 3.5.

    This similar issue describes more. In addition, I have found some alternatives to work on .NET 3.5, you could try to use RestSharp (open source) which support for OAuth, pluggable serialization, and other HTTP concerns.

    BTW, this link gives some references like below and maybe it could help you to consume Web API in project.

    HttpClient client = new HttpClient();
    client.BaseAddress = new Uri("http://[address]/");
    
    // Add an Accept header for JSON format.
    client.DefaultRequestHeaders.Accept.Add(
    new MediaTypeWithQualityHeaderValue("application/json"));
    
    // Create a new product
    var gizmo = new Product() { Name = "Gizmo", Price = 100, Category = "Widget" };
    Uri gizmoUri = null;
                
    HttpResponseMessage response = client.PostAsJsonAsync("api/products", gizmo).Result;
    if (response.IsSuccessStatusCode)
    {
        gizmoUri = response.Headers.Location;
    }
    else
    {
        Console.WriteLine("{0} ({1})", (int)response.StatusCode, response.ReasonPhrase);
    }
    

    Hope this could help you.

    Best Regards,

    Tianyu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, October 7, 2019 2:40 AM
  • Hi v k b,

    Did your issue solved?

    If not please feel free to contact us, and we will try our best to help you.

    Looking forward to hearing from you.

    Best Regards,

    Tianyu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, October 8, 2019 8:00 AM
  • Hi Tianyu, thanks for the reply, but the RestSharp is not getting installed for an sharepoint 2010 solution
    Tuesday, October 15, 2019 3:25 PM
  • Hi v k b,

    Thank you for the feedback.

    I suppose you might want to use HTTPClient or Web Api to develop sharepoint 2010 solution.

    Since our forum is discussing about the usage of tools and editors in Visual Studio, I suggest you could redirect to stack overflow with the tag sharepoint and then start a new thread with sharepoint to seek for a more professional support.

    BTW, I also found some articles that might be helpful for you. Since HttpClient is not available in .net 3.5 and RestSharp might not be able to use with sharepoint 2010 solution, maybe you could refer to this article.

    Really sorry for this inconvenience.

    Best Regards,

    Tianyu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, October 17, 2019 9:44 AM