SAP Knowledge Base Article - Public

3773045 - Error when clearing extension fields using empty string: "Data format for ABC is invalid. Use code"

Symptom

  • You get an error when trying to clear an extension field using API Patch calls
  • Return validation error: “Data format for ABC is invalid. Use CODE”. (ABC is an extension field of format CODE)
  • Issue can occur with extension fields of other Type and Format as well

Environment

SAP Sales Cloud and SAP Service Cloud Version 2

Reproducing the Issue

  1. Select any entity (example: Account).
  2. Perform a PATCH request to the account service endpoint: https://{tenantURL}/sap/c4c/api/v1/account-service/accounts/{UUID}.
  3. Use a body that sends an empty string for the extension field to be cleared, for example:
    { "id": "the id", "displayId": "the id", "extensions": { "ABC": "" } }
  4. Observe the error: “Data format for ABC is invalid. Use CODE”.

Cause

  • Empty string "" is not a valid value for extension fields.
  • SAP Sales and Service Cloud V2 requires that extension fields be explicitly set to null (not an empty string "") when you want to clear them.
  • Passing "" for fields triggers a format validation error and is as expected

Resolution

  1. To clear an extension field, include it in the payload and set its value to null.
  2. Example PATCH body:
    { "id": "the id", "displayId": "the id", "extensions": { "ABC": null } }

See Also

Keywords

extension field, api patch, empty string, null, code list, validation error, data format invalid, use code, clear field, sales and service cloud v2, extensions payload, account service, code value , KBA , CEC-CRM-CZM-EXT , Extensibility for SAP Sales/Service Cloud , How To

Product

SAP Sales Cloud and SAP Service Cloud Version 2 1.0