SAP Knowledge Base Article - Public

3642265 - Error Property '&1' at offset '&2' has invalid value '&3'" 

Symptom

When sending a POST request to an API, e.g.:

  • Sales Order A2X, OData V2 (API_SALES_ORDER_SRV)
  • Commercial Project - Create, Update (/CPD/SC_PROJ_ENGMT_CREATE_UPD_SRV)

The following error occurs:

Property '&1' at offset '&2' has invalid value '&3'" 

Environment

SAP S/4HANA Cloud Public Edition

Reproducing the Issue

Using API Commercial Project - Create, Update (/CPD/SC_PROJ_ENGMT_CREATE_UPD_SRV) as an example and referring to Create Sales Order with Item and Billing Plan Item | SAP Help Portal

POST <host>/sap/opu/odata/sap/CPD/SC_PROJ_ENGMT_CREATE_UPD/A_CustProjSlsOrd
X-CSRF-Token: abc
Content-Type: application/json
Accept: */*

{
    "CustomerProject": "SampleProjectID",
    "PurchaseOrderByCustomer": "API Customer reference",
    "CustomerPurchaseOrderDate": "2019-01-28T00:00:00",
    "PaymentMethod": "F",
    "to_CustProjSlsOrdItem": [
        {
            "SalesOrderItemCategory": "PS01",
            "Material":"P001",
            "ExpectedNetAmount": "500",
            "TransactionCurrency":"EUR",
            "SalesOrderItem":"10",
            "UnderlyingPurchaseOrderItem":"abs12a",
            "SalesOrderItemText": "",
        "to_CustProjSlsOrdItemWorkPckg": [
            {
                "WorkPackage": "SampleProjectID.1.1"
            }
            ],
        "to_CustProjSOIBillgPlnItm": [
            {
                "BillingPlanBillingDate": "2019-01-28T00:00:00",
                "BillingPlanAmount": "100",
                "TransactionCurrency": "EUR",
                "BillingPlanItemDescription": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus luctus urna sed urna ultricies ac tempor dui sagittis. In condimentum facilisis porta. Sed nec diam eu diam mattis viverra. Nulla fringilla, orci ac euismod semper, magna diam porttitor mauris.",
                "BillingPlanItemUsage": ""
            }
            ]
    }
    ]
}

The following error occurs: Property 'BillingPlanItemDescription' at offset '1133' has invalid value 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus luctus urna sed urna ultricies ac tempor dui sagittis. In condimentum facilisis porta. Sed nec diam eu diam mattis viverra. Nulla fringilla, orci ac euismod semper, magna diam porttitor mauris.'

Cause

The value for the field doesn't comply with the fields property.

Fields property for an API can be checked on its metadata, which can be retrieved by the $metadata. Using the Commercial Project as an example, it's metadata could be retrieved on: <host>/sap/opu/odata/CPD/SC_PROJ_ENGMT_CREATE_UPD_SRV/$metadata 

Checking the field BillingPlanItemDescription on the metadata, its properties are the following:

<Property Name="BillingPlanItemDescription" 
          Type="Edm.String" 
          MaxLength="255" 
          sap:label="Description" 
          sap:quickinfo="Billing Plan Item Description"/>

This field is of type 'Edm.String', so no character is invalid, however, its maximum length is '255', so this is causing the error.

The properties of a field exposed by an API can also be checked on the SAP Business Accelerator Hub page for the specific API, the properties are always specified on the example requests.

Resolution

The value send for a specific field must always comply with its properties to be accepted by the system.

See Also

Commercial Project - Create, Update (/CPD/SC_PROJ_ENGMT_CREATE_UPD_SRV) | SAP Help Portal

Commercial Project - Create, Update | SAP Business Accelerator Hub

Keywords

KBA , SD-SLS-API-2CL , API (Public Cloud) , SD-SLS-PBS , Project-Based Services in Sales Documents , Problem

Product

SAP S/4HANA Cloud Public Edition all versions