Sunday, April 14, 2019

RESTLet - URL Encoding for Authentication Password Character - C# (Prevents 401: Error)

When doing Authentication Password, it is good to do URL Encoding for Authentication Password (or nlauth_signature). The reason is, sometime users would have special characters in there password, and NetSuite RESTLet authentication does not accept Special characters unless it is URL Encoded. The following error will then occur: 401 Authorizations Required: INVALID_LOGIN_CREDENTIALS if the correct password has no URL Encoding for Special Characters.

Therefore this article aims to show the function that be can used to do Url Encoding in C#.HttpUtility.UrlEncode(string).

For more information on this function go to: HttpServerUtility.UrlEncode Method (String) -


HttpUtility.UrlEncode(password);// password would be a string variable that would have been initialized before. string url = ""; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.ContentType = "application/json"; request.Method = "GET"; request.Headers.Add("Authorization:NLAuth nlauth_account=1234567,,nlauth_signature=" + password + ",nlauth_role=3");

No comments:

Post a Comment