Inconsistent behaviour REST API when creating/updating worklog properties

Hi all,

I’m currently facing an intriguing issue related to adding a worklog property with a new worklog on the Atlassian platform and would greatly appreciate your insights.

The problem arises when I try to set a key value directly. Here’s the code snippet I’m using:

// POST https://site.atlassian.net/rest/api/2/issue/KEY-123/worklog
{
  "started": "2023-06-12T08:00:02.000+0000",
  "timeSpentSeconds": 3600,
  "properties": [
    {
      "key": "account",
      "value": "a"
    }
  ]
}

Upon executing this, I encounter a 500 Internal server error, which is quite perplexing.

Interestingly, if I nest the value, the operation proceeds without any hitch, and I receive a 201 Created response:

// POST https://site.atlassian.net/rest/api/2/issue/KEY-123/worklog
{
  "started": "2023-06-12T08:00:02.000+0000",
  "timeSpentSeconds": 3600,
  "properties": [
    {
      "key": "account",
      "value": {
        "type": "a"
      }
    }
  ]
}

Even more curious is that when I add a worklog property in a separate API call, I can set the value directly without resorting to any nested workaround:

// PUT https://site.atlassian.net/rest/api/2/issue/KEY-123/worklog/WORKLOGID/properties/account
"a"

Given these observations, I was wondering if anyone else has experienced this inconsistency? Is it a recognized issue or bug within the platform? If so, could you kindly point me in the right direction? Alternatively, are there any other workarounds that would enable me to directly set the key’s value in the initial context?

This behaviour is observed with both the v2 and v3 of the Jira Cloud REST API.

Thanks in advance!

Rick

Hi Rick,

I’ve been trying to reproduce this in a Forge App, however I’m not actually having any success with the following:

I can only seem to get the following error

setProperty Response: 400 Bad Request
{
  errors: {},
  errorMessages: [
    'The JSON data provided for the property is not a valid JSON: olive.'
  ],
  httpStatusCode: { empty: false, present: true }
}

Which is what I’d expect based on the docs at https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-worklog-properties/#api-group-issue-worklog-properties - because the property should be in the form of a key - which is a string, and a value which should be v JSON object.

Can you tell me:

  1. How are you making this call? are you doing this via a curl or some other method?
  2. When you retrieve the property data that you created in your example above, what is the response?

Cheers,
Mel

1 Like

Hi Mel,

Thanks for your reponse. In the meantime I have also reached out to Atlassian Support using support ticket CES-15683. It resulted in 2 new bug reports already and I also found another related bug that is currently being investigated.

Here are the bug reports:
https://jira.atlassian.com/browse/JRACLOUD-81320
https://jira.atlassian.com/browse/JRACLOUD-81321

Thanks

Rick