1
votes

I have to create a issue in jira with POST method using REST API in java but the problem is I am having SSO (Single sign-on) authentication in my system.When I am trying to create ,I am getting 401 (Unauthorized) error.I already have administrator role in project on jira . But I am able to create the issue using POSTMAN(getting 201 response code).I can't understand how POSTMAN is able to do that. Please provide how to do authorization if I have system with SSO authentication.I can't create jira API token as it is restricted to me.

Creating a new "JIRA issue" using REST API in java

I am taking help from this link but here its doing basic authentication.

1

1 Answers

1
votes

You have to use Basic Authentication or OAuth to access the rest api.

        public static string GetEncodedCredentials(string userid, string password)
    {
        string mergedCredentials = string.Format("{0}:{1}", userid, password);
        byte[] byteCredentials = UTF8Encoding.UTF8.GetBytes(mergedCredentials);
        return Convert.ToBase64String(byteCredentials);
    }

Call this method with userid as your username/email, and password using the same password you use in POSTMAN. It is weird that you can do it on POSTMAN and not in your application because I'm assuming you have used this in POSTMAN. This is C# code however so you might need to find the java code for this.

If needed search: Basic Authentication Java Then you will find it.