Skip to content

Configure default grails.databinding.dateFormats in application.yml #4733

@jmiranda

Description

@jmiranda

Related to https://community.openboxes.com/t/error-at-create-product-api/983/8

We should add the default Grails date formats back into our default configuration in 0.9.3. I would recommend starting with those and only configure custom date formats if absolutely necessary.

At a minimum, the API should support the date format used to render dates in the JSON response.

So I should be able to

  1. Create a new transaction using a custom date format

    curl --location 'https://<REDACTED>/openboxes/api/generic/transaction' \
    --header 'Accept: application/json' \
    --header 'Content-Type: application/json' \
    --header 'Cookie: JSESSIONID=<REACTED>' \
    --data '{
        "inventory": "1",
        "transactionType":"11",
        "transactionDate": "07/08/2024 12:03:00", 
        "transactionEntries": [
            {
                "product": "ff808181907703450190797770480000",
                "inventoryItem": "ff8081819077034501908b6f3b1f0020",
                "binLocation": "09f5e1168103c8ba0181496a1a416df2",
                "quantity": "1"
            }
        ]
    }'
    
  2. Get back the following response

    {
        "data": {
            "id": "ff808181909386e80190938a90140000",
            "dateCreated": "2024-07-08T18:10:50Z",
            "lastUpdated": "2024-07-08T18:10:50Z",
            ...
            "transactionDate": "2024-07-08T17:03:00Z",
            ...
        }
    }
    
  3. Copy the transactionDate value returned in the JSON above

    "transactionDate": "2024-07-08T17:03:00Z"
    
  4. Edit the date value

    "transactionDate": "2024-07-08T17:04:00Z"
    
  5. And send a PUT request to update the transaction date

    curl --location --request PUT 'https://<REDACTED>/openboxes/api/generic/transaction/ff808181909386e80190938a90140000' \
    --header 'Accept: application/json' \
    --header 'Content-Type: application/json' \
    --header 'Cookie: JSESSIONID=<REDACTED>' \
    --data '{
        "transactionDate": "2024-07-08T17:04:00Z"
    }'
    

But, that returns the following error.

{
    "errorCode": 400,
    "errorMessage": "Validation error. Cannot create product due to validation errors:\n- Field error in object 'org.pih.warehouse.inventory.Transaction' on field 'transactionDate': rejected value [2024-07-08T17:04:00Z]; codes [org.pih.warehouse.inventory.Transaction.transactionDate.typeMismatch.error,org.pih.warehouse.inventory.Transaction.transactionDate.typeMismatch,transaction.transactionDate.typeMismatch.error,transaction.transactionDate.typeMismatch,typeMismatch.org.pih.warehouse.inventory.Transaction.transactionDate,typeMismatch.transactionDate,typeMismatch.java.util.Date,typeMismatch]; arguments [Date]; default message [Unparseable date: \"2024-07-08T17:04:00Z\"]\n",
    "errorMessages": [
        "Property Date must be a valid Date"
    ]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    domain: backendChanges or discussions relating to the backend serverflag: config changeHilights a pull request that contains a change to the app config

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions