Expected an ISO 8601 date - App Store Connect API

Hi! I am working with App Store Connect API, and I am receiving this error when I want to make a post.

 "'2023-07-12T20:25:38.321Z' is not a valid value for the attribute 'expirationDate'. Expected an ISO 8601 date",

my code is:

const date = new Date(addMonths(new Date(), 1));
  const formattedDate = date.toISOString();

  try {
    const data = {
      attributes: {
        numberOfCodes: 1,
        expirationDate: formattedDate,
      },
      relationships: {
        offerCode: {
          data: {
            id: 'productID',
            type: 'subscriptionOfferCodes',
          },
        },
      },
      type: 'subscriptionOfferCodeOneTimeUseCodes',
    };

    const result = await axios.post(
   'https://api.appstoreconnect.apple.com/v1/subscriptionOfferCodeOneTimeUseCodes',
      { data },
      { headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${token}` } },
    );

Could someone let me know wich is the issue with my date.

I think 2023-07-12T20:25:38.321Z is a ISO 8601 format

Thank you!!

Sometimes the fractions of a second cause problems in ISO8601 date strings. Could it be that? Have you checked how App Store Server API does it: https://github.com/apple/app-store-server-library-swift

Expected an ISO 8601 date - App Store Connect API
 
 
Q