Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,365,413
Community Members
 
Community Events
168
Community Groups

When add worklog via REST API(version 2), get 400 if the worklog contains 'adjustEstimate'

When trying to add worklog like below, get 400 as return code. However if I comments out the two lines with underscore(adjustEstimate and newEstimate), then will get 201 and the worklog can be added successfully.
        auth = self.USER + ':' + self.PASSWORD
        auth = bytes.decode(base64.b64encode(auth.encode('utf-8')))
       
        headers = {
            'Accept': 'application/json',
            'Content-Type': 'application/json',
            'Authorization': 'Basic {}'.format(auth),
        }
       
       worklog = json.dumps({
            'timeSpent':'1h',
            'adjustEstimate':'new',
            'newEstimate':'60h',
            'comment':'add worklog for trial of auto log jira effort'
        })
        res = requests.request(
            'POST',
            url,
            data = worklog,
            headers=headers
        )

1 answer

0 votes

Hey, you can try returning the response to that 400 error to get a better understanding of what the error message says. That will help you to know what's really wrong.

What is the "returning the response to that 400 error " ?

print(res.json())

Do the above in your code on a new line to see what the response is all about.

Great thanks @Prince Nyeche, below are the error msg, seems the adjustEstimate is not supported

{'errorMessages': ['Unrecognized field "adjustEstimate" (Class com.atlassian.jira.issue.fields.rest.json.beans.WorklogJsonBean), not marked as ignorable\n at [Source: org.apache.catalina.connector.CoyoteInputStream@cfc7291; line: 1, column: 41] (through reference chain: com.atlassian.jira.issue.fields.rest.json.beans.WorklogJsonBean["adjustEstimate"])']}

@Prince Nyeche  Do you have more ideas about above error? Seems adjustEstimate is not supported, but this is not aligned with the API user guide for API2  https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-issue-worklogs/#api-rest-api-2-issue-issueidorkey-worklog-post

You should not use adjustEstimate and newEstimate as body parameters. They should be used as query parameters instead accordingly to the documentation. Therefore, use it as parameters to your url variable.

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events