I was able to GET and DELETE, but I was not able to POST or PUT. I was able to make all calls using Basic Authentication but not OAuth. I followed the tutorial from https://developer.atlassian.com/cloud/jira/platform/jira-rest-api-oauth-authentication/ . The example only uses GET. I used the same API for POST, PUT, and DELETE which is required to create, edit and delete a a JIRA issue.
I get the com.google.api.client.http.HttpResponseException: 400 Bad Request
{"errorMessages":["Can not instantiate value of type [simple type, class com.atlassian.jira.rest.v2.issue.IssueUpdateBean] from JSON String; no single-String constructor/factory method"]}
It appears to be a common problem from a quick Google search, but I am unable to find a solution. Could you point me to the right resources to make it work – forums or other source of development help.
For example, I tried to make a POST call to create an issue passing in this JSON:
{
"fields": {
"summary": "JUNIT testCreateDeleteIssue() Tue Oct 03 13:57:25 EDT 2017",
"issuetype":
{ "name": "Bug" },
"project":
{ "key": "HELLO" }
}
}
I get the following error:
com.google.api.client.http.HttpResponseException: 400 Bad Request
{"errorMessages":["Can not instantiate value of type [simple type, class com.atlassian.jira.rest.v2.issue.IssueUpdateBean] from JSON String; no single-String constructor/factory method"]}
at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1070)
Code use to create HttpContent:
HttpContent content = new JsonHttpContent(new JacksonFactory(), jsonString);
Code to POST
HttpRequestFactory requestFactory = nt.createRequestFactory(parameters);
HttpRequest request = requestFactory.buildPostRequest(jiraUrl, content);
request.execute();