Jira authentication with Java

Hi,

I try to create user using Java and REST API, but when i do it i have a 401 error. It is a user is not authenticated error. How i can authenticat with java and REST?

Maybe somebody have some code exfmple?

1 answer

1 accepted

0 votes
Accepted answer

With Jersey Client

ClientResponse response;
String auth = new String(Base64.encode("username" + ":" + "password"));
final String headerAuthorization = "Authorization";
final String headerAuthorizationValue = "Basic " + auth;
final String headerType = "application/json";
Client client = Client.create();

WebResource webResource = client.resource("url");
response =  webResource.header(headerAuthorization, headerAuthorizationValue).type(headerType).accept(headerType).get(ClientResponse.class);

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Jan 08, 2019 in Jira

How to Jira for designers

I’m a designer on the Jira team. For a long time, I’ve fielded questions from other designers about how they should be using Jira Software with their design team. I’ve also heard feedback from other ...

1,092 views 4 9
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you