Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Unauthorized 401 error for create user in fisheye how can solve this error?

MayankPatel January 20, 2015

Hi,

I am facing error for create user  "Unauthorized 401" using fisheye.

My code is below for better understanding for trace my bug.

I am using c#.net for creating this fisheye user.

Error Like "

An exception of type 'System.Net.WebException' occurred in System.dll but was not handled in user code

Additional information: The remote server returned an error: (401) Unauthorized. "

 

string strCreateUserJson = "{ \"name\" : \"" + strUserName + "\",\"password\" : \"" + strPassword + "\",\"displayName\" : \"" + strDisplayName + "\",\"email\" :\"" + strEmailId + "\",\"type\" : \"built-in\",\"crucible\" : true}";

string strURI = "http://localhost:8060/rest-service-fecru/admin/users";  


HttpWebRequest request = WebRequest.Create(strURI) as HttpWebRequest;

            request.ContentType = "application/json";

            request.Method = "POST";

            request.ContentLength = strJsonDatatoPass.Length;

 

            string base64Credentials = GetEncodedCredentials();

            request.Headers.Add("Authorization", "Basic " + base64Credentials);

 

            using (StreamWriter writer = new StreamWriter(request.GetRequestStream()))

            {

                writer.Write(strJsonDatatoPass);

            }

 

            HttpWebResponse response = request.GetResponse() as HttpWebResponse;

 

            string result = string.Empty;

            using (StreamReader reader = new StreamReader(response.GetResponseStream()))

            {

                result = reader.ReadToEnd();

            }

What can assigne for username and password for fisheye admin ?

I don't know or i ma entering wrong username and password for create user in fisheye.

 

private string GetEncodedCredentials()
    {
	string mergedCredentials = string.Format("{0}:{1}", strUserName, strPassword);
             byte[] byteCredentials = UTF8Encoding.UTF8.GetBytes(mergedCredentials);
             return Convert.ToBase64String(byteCredentials);
    }

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
MayankPatel January 20, 2015

Now done it after set user set to admin role.

and it's username and password to GetEncodedCredentials() method it's strUserName, strPassword
Upon code have not any bug.
Thanks,
0 votes
rahuldanwade
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 20, 2015

Hi Mayank,

I think user logged in JIRA side either doesn't exist in FishEye side or is not among the groups allowed to read the repository.

MayankPatel January 20, 2015

Hi Rahul, Thanks for replay but actually this is not a problem i already set this groups allowed to read the repository. Thanks

TAGS
AUG Leaders

Atlassian Community Events