Server returned HTTP response code:500 for URL:

Source: Internet
Author: User
Tags response code

When invoking the URLConnection POST request on the Java backend, the browser test (ASMX) is normal, and the Java back-end returns the server returned HTTP response code:500 for URL:


Problem reason after carefully checking URL and request parameters

1 could be a coding problem.

2 need to set the following content


Conn.setrequestproperty ("Connection", "keep-alive");
Conn.setrequestproperty ("Charset", "GBK");
Set File type: Form submission Key-value
Conn.setrequestproperty ("Content-type", "application/x-www-form-urlencoded; CHARSET=GBK");
Set Receive type otherwise return 415 error
Conn.setrequestproperty ("Accept", "*/*") here for Brute force method settings Accept all types, in order to guard against returning 415;


conn.setrequestproperty ("User-agent", "mozilla/4.0" (compatible; MSIE 5.0; Windows NT; Digext) ");
Send POST request must be set as follows two lines
Conn.setdooutput (TRUE);
Conn.setdoinput (TRUE);



After setting, request again, normal call.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.