This article addresses the error encountered when using the Basware API, specifically the validation error "ValidFrom is required." It explains the root cause and provides a solution to resolve this issue.
When submitting a POST request to the Basware API for the payload that contains ValidFrom/ValidTo dates, for example ExchangeRates, Users, /v2/Projects...etc. you may receive error 400 Bad request with the following error message:
'ValidFrom is required' even though the ValidFrom date is present in the payload.
The error occurs because the validFrom date in the payload contains a year value that is not accepted by the Basware API. Specifically, the API rejects dates with a year earlier than 2000. For example, using the year 1952 will trigger this error.
To resolve this error, update the validFrom date in the payload to use a year of 2000 or later. The following example demonstrates a valid payload structure with an acceptable validFrom date:
[
{
"projectCode": "XYZproject",
"projectName": "XYZ project name",
"description": "XYZ project description",
"validFrom": "2000-01-01T00:00:00.000-05:00",
"validUntil": "2025-03-31T00:00:00.000-04:00",
"companies": [
{
"companyCode": "XYZ_Company",
"active": true
}
],
"externalCode": "XYZ_externalcode"
}
]
As a best practice, you may implement logic on your side to automatically substitute any validFrom dates earlier than 2000-01-01 with the date 2000-01-01 before sending the payload to the API. This will help prevent similar errors in the future.
Please update the validFrom field accordingly and retry the API call. If you encounter any further issues, feel free to reach out for assistance.
Additional Information:
In case you have additional queries related to this article and any issue arises after using the solution suggested please reach out to Basware Support through a ServiceNow case.