Skip Navigation
Expand
Mandatory fields with optional ancestors shown as optional in Connect REST API documentation
Answer ID 12520   |   Last Review Date 01/10/2023

Why does the field manualStrength on the answers-relatedAnswers sub-object of answers say it is optional on PATCH requests when it is actually mandatory?

Environment
 
  • Connect REST API
  • All versions
 
Issue:
 
Trying to update an object with a PATCH request to the REST API. All the fields say they are optional in the documentation and schema. But we get an error like this:
 
{
    "type": "https://<site>/services/rest/connect/exceptions/OSC-CREST-00006",
    "title": "An attempt to write a resource failed",
    "status": 400,
    "detail": "Required on update; Answer(ID=1).RelatedAnswers[0].ManualStrength",
    "instance": "https://<site>/services/rest/connect/latest/answers/1",
    "o:errorCode": "OSC-CREST-00006"
}
 
Resolution:
 
  • The REST API documentation says that a field is optional if any of its ancestors are optional.
  • Everything is optional at the top level in a PATCH request.
  • All descendants are also marked optional because of that.
  • Some fields may have different restrictions based on whether the sub-object is being created or updated, either of which could be done in a PATCH request.
  • The Connect for PHP documentation has tables for every sub-object with the differences in field requirements based on whether the child is being created or updated.
  • Technical Documentation and Sample Code links to the documentation for both Connect REST and PHP APIs