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