Friday, September 21, 2018

Eliminate HTTP 405 Error when Posting to Externally Available Suitelets

Customer is using a third party application written in Java, .Net etc. He is Posting data to an externally available Suitelet but he encounters HTTP 405 Error every time he passes the request to the Suitelet and gets the response.

In order to eliminate the error, user should also specify headers on the request. Below is a sample code in Java to add request headers:

URL url = new URL("https://forms.netsuite.com/app/site/hosting/scriptlet.nl");
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();

Connection.setRequestProperty("User-Agent", "Mozilla/5.0");
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8");
connection.setRequestProperty("Accept-Language", "en-us,en;q=0.5");
connection.setRequestProperty("Accept-Encoding", "gzip,deflate");
connection.setRequestProperty("Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.7");

3 comments:

  1. Hi,
    This is not working for me. I am still facing "Method Not Allowed" HTTP 405 error.

    ReplyDelete
  2. This header made the trick for me:
    "User-Agent", "Mozilla/5.0"

    Working fine now

    ReplyDelete