Skip to Content
0
May 18, 2020 at 08:08 AM

SAP Cloud SDK for JavaScript: unable to post entry with a date field

2821 Views

Hi,

I am trying to create a material document header using the following request payload which has postingdate as mandatory field.

MaterialDocumentHeader {
  goodsMovementCode: '01',
  postingDate: '2020-04-11T10:00:00',
  toMaterialDocumentItem: [
  // not relevant 
}

When I try to post, console says the following. Seems like issue with Datetime conversion.

TypeError: momentInstance.unix is not a function
    at Object.momentToEdmDateTime (C:\Users\xxx\my-sdk-project\node_modules\@sap-cloud-sdk\core\dist\payload-value-converter.js:82:36)
    at Object.tsToEdm (C:\Users\xxx\my-sdk-project\node_modules\@sap-cloud-sdk\core\dist\payload-value-converter.js:32:36)
    at C:\Users\xxx\my-sdk-project\node_modules\@sap-cloud-sdk\core\dist\entity-serializer.js:47:75
    at Array.reduce (<anonymous>)
    at serializeEntityNonCustomFields (C:\Users\xxx\my-sdk-project\node_modules\@sap-cloud-sdk\core\dist\entity-serializer.js:40:32)
    at Object.serializeEntity (C:\Users\xxx\my-sdk-project\node_modules\@sap-cloud-sdk\core\dist\entity-serializer.js:26:34)
    at CreateRequestBuilder.prepare (C:\Users\xxx\my-sdk-project\node_modules\@sap-cloud-sdk\core\dist\request-builder\create-request-builder.js:84:58)
    at CreateRequestBuilder.<anonymous> (C:\Users\xxx\my-sdk-project\node_modules\@sap-cloud-sdk\core\dist\request-builder\create-request-builder.js:110:22)
    at step (C:\Users\xxx\my-sdk-project\node_modules\@sap-cloud-sdk\core\dist\request-builder\create-request-builder.js:47:23)
    at Object.next (C:\Users\xxx\my-sdk-project\node_modules\@sap-cloud-sdk\core\dist\request-builder\create-request-builder.js:28:53)

Anyone faced this issue before? Or am I doing anything wrong?

Regards,

Tejaswi