SAP Knowledge Base Article - Public

3514054 - Resolving DateTimeParseException in Case Management POST Requests Due to Incorrect reportedOn Timestamp Format

Symptom

  • This article addresses a common issue encountered when submitting a POST request to the Case Management service.
  • Specifically, it provides guidance on resolving DateTimeParseException errors caused by incorrect date formats in the reportedOn field.
  • This error occurs when the reportedOn field in the JSON payload contains a date and time string that does not comply with the expected format.

Environment

  • SAP Service Cloud Version 2 1.0
  • SAP Sales Cloud Version 2 1.0

Cause

  • The java.time.Instant class, which is used to parse date and time strings in the backend, expects the date to be in a specific format (ISO 8601).
  • The error is triggered if the string includes an unrecognized format, such as a timezone offset with milliseconds.

Resolution

  • To resolve this issue, the reportedOn field must be formatted correctly.
  • There are two possible options options. Below are steps to format the date and time string in the JSON payload.
    1. Use UTC Format: The recommended approach is to use the UTC format for the reportedOn field.
      • Ensure the timestamp ends with a 'Z' to denote UTC time.
      • Example: "reportedOn": "2024-08-13T09:14:51.842Z"
    2. Simplified Date Format (if applicable): If milliseconds are not necessary, you may omit them and provide a simpler date and time format.
      • This format should be accepted by the server.
      • Example: "reportedOn": "2024-08-13T09:14:51+00:00"
  • Administrators can perform the above using tools like Insomnia, Postman or the API Business Accelerator Hub 
    • Steps to Resolve the Issue in Insomnia:
      1. Open Insomnia:
      2. Create or Open the POST Request:
        • If you already have a POST request created for the Case Management service, open it.
        • Otherwise, create a new request by clicking on the + icon and selecting New Request.
        • Name your request (e.g., "Create Case Request") and choose the POST method.
      3. Enter the Request URL:
      4. Set Up the JSON Body:
        1. Click on the Body tab.
        2. Select the JSON option from the dropdown menu.
        3. Paste the JSON payload in the body, ensuring the reportedOn field is correctly formatted.
          Example (replace the variables according to your needs and add any additional fields which are mandatory):
          {
              "subject": "Complaint",
              "priority": "01",
              "caseType": "CASE_TYPE",
              "statusSchema": "STATUS_SCHEMA",
              "status": "STATUS_CODE",
              "timePoints": {
                  "reportedOn": "2024-08-13T09:14:51.842Z" //or use "reportedOn": "2024-08-13T09:14:51+03:00" but not both.
              },
              "individualCustomer": {
                  "id": "12345678-1234-1234-1234-123456789012"
              }
          }

Keywords

DateTimeParseException, Case Management, POST Request, Insomnia, Java Time Instant, ISO 8601 Format, Timestamp Format, Bad Request Error, reportedOn Field, JSON Parse Error, API Troubleshooting, CRM Cloud, Time Zone Offset, UTC Format, Error Resolution, SAP C4C, Service Cloud V2, API Call , KBA , CEC-CRM-CAS , Case Management for SAP Sales/Service Cloud , Problem

Product

SAP Sales Cloud and SAP Service Cloud Version 2 1.0