Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8222397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T14:15:55+00:00 2026-06-07T14:15:55+00:00

I am doing a HTTP PUT using the WebClient class for a JSON string

  • 0

I am doing a HTTP “PUT” using the WebClient class for a JSON string to an Elastic Search. This code works in 95% of the cases but fails for the rest. The error I get is 400 bad protocol in my code. When I post the same JSON using jQuery AJAX or a Chrome extension called Postman, it works flawlessly. I am not sure how to get around this error. My code is below –

string json = "{some json}";
WebClient client = new WebClient();
client.Headers["Content-Type"] = "application/json;charset=UTF-8";    

try
{
     json = client.UploadString(URL, "PUT", json);
}
catch (WebException ex)
{
     //catch exception
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T14:15:56+00:00Added an answer on June 7, 2026 at 2:15 pm

    Elastic Search expects some headers which WebClient does not pass. I used HttpWebRequest class and it worked fine without any errors since.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am doing this tutorial but with a diferent xml http://blog.insicdesigns.com/2009/03/parsing-xml-file-using-codeigniters-simplexml-library/ , but I
I am doing: html = new WebClient().DownloadString( http://www.google.com/search?sourceid=chrome&ie=UTF-8&q= + biocompany); and i am getting
I am doing something like this- http://www.w3schools.com/html5/tryit.asp?filename=tryhtml5_video_js_prop but I want to replace the buttons
I've put this information into a pastie, but repeated it here (pastie link http://pastie.org/private/4vprzwhllqv35egrf8jzwg
I am doing a very simple search on my DB using acts_as_ferret. I put
How do you do do an HTTP PUT? The class I'm using seems to
I'm just doing a simple graph using Open Flash Chart http://teethgrinder.co.uk/open-flash-chart/ which shows the
I'm attempting to process the body of an HTTP PUT request, but it seems
I'm using a UISearchDisplayController with a UISearchBar. I put this UISearchBar in my app
At work I am parsing large XML files using the DefaultHandler class. Doing that,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.