Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.
×Hi,
I'm trying to send a post request to Jira using 2-Legged OAuth, but I don't know where to put the username to be impersonated
private JSONObject handlePostRequest(PropertiesCall arguments) {
Map<String, String> properties = propertiesClient.getPropertiesOrDefaults();
String url = properties.get(JIRA_HOME) + arguments.getApi();
try {
OAuthParameters parameters = this.getOAuthParameters();
HttpResponse response = sendResponsePostFromUrl(parameters, new GenericUrl(url), arguments);
return parseResponse(response);
} catch (HttpResponseException e) {
log.error(e.getMessage());
return new JSONObject(e.getContent());
} catch (Exception e) {
log.error(e.getMessage());
return null;
}
}
private static HttpResponse sendResponsePostFromUrl(OAuthParameters parameters, GenericUrl jiraUrl,
PropertiesCall arguments) throws IOException {
HttpRequestFactory requestFactory = new NetHttpTransport().createRequestFactory(parameters);
HttpRequest request = requestFactory.buildPostRequest(jiraUrl,
ByteArrayContent.fromString("application/json", arguments.getParametros()));
return request.execute();
}