I have looked at a number of posts here and can't seem to figure out what I'm doing wrong. I would like to use the Rest Api to add a worklog to an issue.
request:
resource: "/rest/api/2/issue/TEST-93/worklog"
method: POST
using Basic Authentication
requestbody: {\"worklog\":[\"add\",{\"timeSpent\":\"1m\",\"timeSpentInSeconds\":\"60\",\"comment\":\"integration test successful\"}]}}
I keep an getting "Unrecognized field \"update\"" error from the server.
I can create an issue without a problem, but can't seem to figure out the correct syntax for adding a worklog to an issue via the API.
Can anyone help? Thanks!
Community moderators have prevented the ability to post new answers.
the json string should be like this
{ "self": "http://www.example.com/jira/rest/api/2.0/issue/TEST-1/worklog/10000", "author": { "self": "http://www.example.com/jira/rest/api/2.0/user?username=fred", "name": "fred", "displayName": "Fred F. User", "active": false }, "updateAuthor": { "self": "http://www.example.com/jira/rest/api/2.0/user?username=fred", "name": "fred", "displayName": "Fred F. User", "active": false }, "comment": "I did some work here.", "started": "2012-02-15T17:34:37.937-0600", "timeSpent": "3h 20m", "timeSpentSeconds": 12000, "id": "100028" }
Thanks again, appreciate all the feedback. I copied and pasted your string and inserted my values except for the id. Since I'm trying to add a worklog, I don't believe an id exists yet. When I run it though, I'm getting: \"timeSpent\":\"A value is required for manual estimate adjustment\"}
I do have a value for timeSpent though: "timeSpent": "1m".
Any ideas? Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
String data = "{\"fields\":{\"worklog\":[\"add\",{\"timeSpent\":\"1m\",\"timeSpentInSeconds\":\"60\",\"comment\":\"integration test successful\"}]}}";
I am using the above JSON string to add new worklog to my JIRA ticket.
But, its throwing
status code [405], status message [Method Not Allowed]
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
i think you have to change the request body
check this
https://docs.atlassian.com/jira/REST/latest/#idp1978400
if you want to Updates an existing worklog entry using its JSON representation
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for the response. I've been looking at the documentation and even found this post: https://answers.atlassian.com/questions/139686/how-to-log-work-then-resolve-issue-using-rest-api which is what I modeled my call after. I'm still unsure how I have to restructure the body of the request. Could you provide a simple example? Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.