Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Error while updating assets with dates via the REST API

DB December 14, 2023 edited
When updating or creating assets with a date via the REST api I receive the following error.
Your code had an error! Traceback (most recent call last): File "<string>", line 110, in the_function File "<string>", line 39, in update_object Exception: Failed to update object. Status code: 400. Response text: {"errorMessages":[],"errors":{"rlabs-insight-attribute-211":"2024-18-09T00:00:00.000+00:00 is not valid (Date)"}}
What is the correct date format? I've tried:
2024-18-09T00:00:00.000+00:00
2024-18-09T00:00:00Z
2024-18-09T00:00:00.000Z
2024-18-09
18-09-2024
09-18-2024
All result in the same issue. I can only find this article that suggests my date format is correct.
I've also tested with a new Attribute using DateTime. This also doesn't work.
Your code had an error! Traceback (most recent call last): File "<string>", line 110, in the_function File "<string>", line 39, in update_object Exception: Failed to update object. Status code: 400. Response text: {"errorMessages":[],"errors":{"rlabs-insight-attribute-247":"\"2024-09-18T00:00:00.000Z\" is not valid (DateTime)"}}

I've manually set the DateTime in the asset, copied the value that is returned for the DateTime value and it still fails.

            "objectTypeAttributeId": "247",

            "objectAttributeValues": [

                {

                    "value": "2024-09-18T00:00:00.000Z",

                    "displayValue": "18/Sep/24 12:00 AM",

                    "searchValue": "2024-09-18T00:00:00.000Z",

                    "referencedType": false

                }

            ],

            "objectId": "7878"

I'm not sure if theres a bug in the Date and DateTime asset API or I'm making a very simple error. If I do not escape the quotes are the time it reports that its not serializable json, which is a bit odd...

1 answer

0 votes
DB December 15, 2023

There was actually a formatting issue with my json payload which was causing the date issue.

Joshua Hindman February 21, 2025

I know this is a long shot being 2 years old, but what was the final format answer and issue you were having with the JSON payload? Having this issue now and it's driving me nuts.

Thanks.

Like Leonel Goitia likes this
Leonel Goitia February 21, 2025
This one worked fine for me
{
    "attributes": [
        {
            "objectTypeAttributeId": 2938,
            "objectAttributeValues": [
                {
                    "value": "2024-09-18T00:00:00.000Z"
                }
            ]
        }
    ]
}
Like Joshua Hindman likes this
Joshua Hindman February 21, 2025

Thank you!!! That'll be a huge help. Now to get everything to play nice. Really hate working with dates / times in Atlassian products.

Thanks again!

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
atlassian, jira cloud certification, managing jira projects, jira project administration, jira cloud exam, atlassian certification, agile project management, jira workflows, jira permissions, jira training, jira cloud skills, atlassian learning

Become a Certified Jira Service Project Expert 🦸🏻‍♂️

Validate your expertise in managing Jira Service Projects for Cloud. Master configuration, optimize workflows, and manage users seamlessly. Earn global 🗺️ recognition and advance your career as a trusted Jira Service management expert.

Get Certified! ✍️
AUG Leaders

Atlassian Community Events