cancel
Showing results for 
Search instead for 
Did you mean: 

CAP Request Builder converts Number into String

Sergen_Batman
Explorer
0 Kudos

Hi Experts,

I am trying to consume an OData v4 Service trough CAP. The Entity Builder for the Purchase Requisition Service works as expected. This is how my entity looks in CAP.

However - when I send the request to an SAP S/4HANA System using the Request Builde, the number field gets converted to a string with double quotes and I get an XML parsing Error. The request would work without the double quotes(Tested with Postman).

I am using the Odata Client as mentioned in the API Business Hub: https://api.sap.com/api/OP_PURCHASEREQUISITION_0001/cloud-sdk/JavaScript

Any hint would be highly appreciated. Below my code snippet.

const purReqItems = req.data.PurchaseReqn._PurchaseRequisitionItem // create an array of requests to create the PR item entities const itemsArray = purReqItems.map((item: PurchaseReqnItem) => purchaseReqnItemApi.entityBuilder(). purchaseRequisitionItemText( item.PurchaseRequisitionItemText). accountAssignmentCategory( item.AccountAssignmentCategory). materialGroup( item.MaterialGroup). baseUnit( item.BaseUnit). purchaseRequisitionPrice(12). purReqnItemCurrency( item.PurReqnItemCurrency). purchasingGroup( item.PurchasingGroup). plant( item.Plant). companyCode( item.CompanyCode). requestedQuantity(10). build())

// Create PR Header Entity const purReq = purchaseReqnApi.entityBuilder(). purReqnDescription(req.data.PurchaseReqn.PurReqnDescription). purchaseRequisitionType(req.data.PurchaseReqn.PurchaseRequisitionType). purchaseRequisitionItem(itemsArray).build()
const sapResult = await purchaseReqnApi.requestBuilder().create( purReq).addCustomHeaders({'Content-Type' : 'application/json;IEEE754Compatible=true'}).execute( destination)

Accepted Solutions (0)

Answers (1)

Answers (1)

martinstenzig
Contributor
0 Kudos

Have you checked the meta data of your SAP interface for that field?