-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Date Time Issue In Batch Request #5100
Comments
this is complete code const { zgwCsscSrv } = require('../services/ZGW_CSSC_SRV'); const formatToTimestampDate = (date) => { module.exports = async (req) => {
}; |
Hey @rpathak-max, I think you are using the wrong assumptions on how Let me know if that helps. |
Hi @marikaner, thank you for your reply. can you please guide me with any docs and any sample how can i pass instance of moment because i have tried with moment library but still facing that error. may be you can share some example of it if its possible. |
Sure: const moment = require('moment');
const createOrderRequestBuilder = zcssc_C_Order_HeaderApi.requestBuilder().create(
zcssc_C_Order_HeaderApi.entityBuilder().fromJson({
orderDate: moment(),
// ...
})
); Is this what you tried? |
No i have to pass the order date which i mentioned as request payload so first i passed that date to the moment and then assigned it i a variable then passed it to the orderDate can you please share the example of that like passing the parameter from postman and convert it into the instance. this is the format i am passing from postman "/Date(1603843200000)/" |
As I pointed out before, you have two options:
|
Ok let me try this solution then i will let you know thank you for your support |
Hi @rpathak-max , were you able to resolve your issue using @marikaner 's suggestion? |
Hello @deekshas8, I apologize for the delayed response, and I wanted to express my sincere gratitude for your support. I’m pleased to inform you that the issue has been resolved, thanks to your invaluable assistance. I greatly appreciate your patience and guidance throughout this process. Thank you once again for your support. |
Describe the bug I'm encountering an issue with the SAP Cloud SDK when generating a batch request in Node.js. The error occurs specifically when trying to handle a Date field (orderDate) during batch processing. The error message is:
Error during batch request: TypeError: momentInstance.unix is not a function
The issue seems to arise from the use of date handling and serialization, as shown in the error trace:
serializeFromMoment (/home/vcap/app/node_modules/@sap-cloud-sdk/odata-v2/dist/de-serializers/converters.js:62:38)
To Reproduce Steps to reproduce the behavior:
Set up a Node.js project using the SAP Cloud SDK for OData V2.
Create a batch request with a Date field formatted using a custom function like formatToTimestampDate.
Send the request to an OData service using the SAP Cloud SDK.
Observe the error when processing the orderDate field.
Expected behavior The orderDate should be correctly serialized and processed without throwing the momentInstance.unix error, and the batch request should execute successfully.
Screenshots N/A
Used Versions:
Node.js version: v16.13.0
npm version: 8.1.0
SAP Cloud SDK version: 1.59.0
Code Examples The code snippet below is where the error is triggered. The error occurs when setting the orderDate field in the batch request.
Log file Here’s the relevant part of the error stack trace:
Impact / Priority
Affected development phase: Development
Impact: Blocked
Timeline: Go-Live is in 1 weeks.
Additional context The issue appears to stem from how the SDK handles the Date field (orderDate). I’ve attempted various methods to format the date, including using the /Date()/ format as shown in the code, but it consistently leads to this issue.
The text was updated successfully, but these errors were encountered: