How to add attachment using oauth accessToken (not userName & password) ?
Codes below can only do normal post to Jira (create issue or add comment):
OAuthAccessor accessor = getAccessor();
OAuthClient client = new OAuthClient(new HttpClient4());
accessor.accessToken = accessToken;
OAuthMessage request = accessor.newRequestMessage(method, url, Collections.<Map.Entry<?, ?>>emptySet(), bodyAsStream);
List<Map.Entry<String, String>> headers = request.getHeaders();
headers.add(new OAuth.Parameter(HttpMessage.CONTENT_TYPE, "application/json"));
headers.add(new OAuth.Parameter(HttpMessage.CONTENT_LENGTH, contentLength));
headers.add(new OAuth.Parameter(HttpMessage.DEFAULT_CHARSET, "UTF-8"));
OAuthMessage response = client.invoke(request, ParameterStyle.AUTHORIZATION_HEADER);
Unlock your potential and learn how to use Jira Product Discovery to your advantage. You’ll have the expertise to revolutionize ideas and insights, roadmapping, engage and align teams and stakeholders, and deliver the best solutions—faster. Enroll today!
Start Learning