2

I am attempting to insert work logs into JIRA using the REST API from my NodeJS backend. I am able to get it to work successfully from my local environment but when I deploy (to a dockerized managed service provider that I don't have a TON of control over), the entries are rejected by JIRA with the following error:

started: Invalid date format. Please enter the date in the format "yyyy-MM-dd'T'HH:mm:ss.SSSZ".

I have attempted no less than 15 variations on my approach here at this point and none of them will work on the deployed server.

The code I am using to format the date successfully when I run locally utilized the date-fns library:

started: format(parseISO(entryStartTime), "yyyy-MM-dd'T'HH:mm:ss.SSSXX")

I have also attempted other approaches using other formatting strings, and even tried switching to MomentJS to see if I would get a different outcome (I did not).

I logged what the date string looks like in both instances - does anyone have any idea what I might be doing wrong here?

Local - working
Time entry before format: 2021-07-14T13:00:12+00:00
Time entry after format: 2021-07-14T07:00:12.000-0600

Server - NOT working
Time entry before format: 2021-07-14T13:00:12+00:00
Time entry after format: 2021-07-14T13:00:12.000Z

2
  • 1
    Considering entryStartTime is in a format supported by ECMA-262, try not using date-fns and just do new Date(entryStartTime).toISOString(). Commented Aug 3, 2021 at 22:13
  • @RobG - that appears to give me the same output without using date-fns, however I also receive the same error message. Commented Aug 3, 2021 at 23:11

1 Answer 1

1

I was able to ultimately get it to work using the Moment format string:

YYYY-MM-DDTHH:mm:ss.SSSZ
Sign up to request clarification or add additional context in comments.

3 Comments

Can you show the whole request? I'm facing the same error with posting {"comment":"foobar","started":"2021-08-25T13:45:00.000Z","timeSpentSeconds":900} which looks to be a perfectly valid date
@NitrusCS as of 2021-12-11 it looks like the error message is wrong. The API is expecting date-time to be 2021-08-25T13:45:00.000+0000. At least when I change it to that it works. The curl example also shows that date-time format: developer.atlassian.com/cloud/jira/platform/rest/v3/…
Yea, I couldn't figure out a way to make C# output that format natively, so I had to do it in stages: String offSetSpecifier= StartDateTime.ToString("zzzz").Replace(":", ""); StartDate = StartDateTime.ToString("yyyy-MM-dd'T'HH:mm:ss.fff") + offSetSpecifier;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.