unable to Send POST request to JIRA - OAuth Java

Deleted user March 15, 2018

Hello,

Ive been trying to create issues in Jira using JAVA and Oauth . I followed the tutorial and using the sample oauth client provided in the below link:

https://developer.atlassian.com/server/jira/platform/oauth/#JIRARESTAPIExample-OAuthauthentication-ExampleJavaOAuthclient

I am able to successfully send GET requests and have also added DELETE which is working great, but im not able to figure out how to submit a POST request. The code im using is below:

private static HttpResponse postResponseFromUrl(OAuthParameters parameters, GenericUrl jiraUrl, String requestBody) throws IOException {
HttpRequestFactory requestFactory = new NetHttpTransport().createRequestFactory(parameters);
HttpRequest request = requestFactory.buildPostRequest(jiraUrl, ByteArrayContent.fromString(null, requestBody));
return request.execute();
}


When i run the above, i get a 401 error with no other detail. I thought it might have to do with a json formatting but I am able to successfully create issues with basic authentication using POSTMAN. But when i attempt to POST using the OAuth sample project, i get the 401 error which is odd, as I can DELETE and GET just fine.

Would really appreciate any advice.

Many thanks

 

 

2 answers

0 votes
Praseeda Sathaye June 15, 2019

@[deleted] I also get the same issue. Did you get this resolved?. I dont see any answers in https://community.developer.atlassian.com either.

0 votes
Moga
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 26, 2018

This looks like a developer question, so it would be better to post it at https://community.developer.atlassian.com, that's where our developer community hangs out :)

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events