Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

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

jingga September 6, 2022
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
Prince Nyeche
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 7, 2022

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.

jingga September 17, 2022

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

Prince Nyeche
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 18, 2022
print(res.json())
Prince Nyeche
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 18, 2022

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

jingga September 19, 2022

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"])']}

jingga September 26, 2022

@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

Prince Nyeche
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 27, 2022

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.

Like jingga likes this
jingga October 27, 2022

Great thanks and now according to your suggestions, the interface has been called successfully.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events