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
-
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"
}
]
}'
-
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",
...
}
}
-
Copy the transactionDate value returned in the JSON above
"transactionDate": "2024-07-08T17:03:00Z"
-
Edit the date value
"transactionDate": "2024-07-08T17:04:00Z"
-
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"
]
}
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
Create a new transaction using a custom date format
Get back the following response
Copy the transactionDate value returned in the JSON above
Edit the date value
And send a PUT request to update the transaction date
But, that returns the following error.