on 2023 Aug 29 1:05 PM
Hi All,
I am trying to post the timesheet data to my public cloud system through CAPM but getting "CSRF token validation failed" error.
I am using "https://api.sap.com/api/API_MANAGE_WORKFORCE_TIMESHEET/overview" API , here we can API structure is different. Fields which are coming in Complex Type i.e. (TimeSheetDataFields) are not accessible.
below is my payload:-
{
"TimeSheetDataFields": {
"ControllingArea": "string",
"SenderCostCenter": "string",
"ReceiverCostCenter": "string",
"InternalOrder": "string",
"ActivityType": "string",
"WBSElement": "string",
"WorkItem": "string",
"BillingControlCategory": "string",
"PurchaseOrder": "string",
"PurchaseOrderItem": "string",
"TimeSheetTaskType": "string",
"TimeSheetTaskLevel": "string",
"TimeSheetTaskComponent": "string",
"TimeSheetNote": "string",
"RecordedHours": "0",
"RecordedQuantity": "0",
"HoursUnitOfMeasure": "string",
"RejectionReason": "string",
"TimeSheetWrkLocCode": "string",
"TimeSheetOvertimeCategory": "string",
"SenderPubSecFund": "string",
"SendingPubSecFunctionalArea": "string",
"SenderPubSecGrant": "string",
"SenderPubSecBudgetPeriod": "string",
"ReceiverPubSecFund": "string",
"ReceiverPubSecFuncnlArea": "string",
"ReceiverPubSecGrant": "string",
"ReceiverPubSecBudgetPeriod": "string"
},
"PersonWorkAgreementExternalID": "string",
"CompanyCode": "string",
"TimeSheetRecord": "string",
"PersonWorkAgreement": "string",
"TimeSheetDate": "/Date(1492098664000)/",
"TimeSheetIsReleasedOnSave": true,
"TimeSheetPredecessorRecord": "string",
"TimeSheetStatus": "string",
"TimeSheetIsExecutedInTestRun": true,
"TimeSheetOperation": "string"
}
Sample Payload:-
{
"TimeSheetDataFields": {
"ControllingArea": "A000",
"SenderCostCenter": "",
"ReceiverCostCenter": null,
"InternalOrder": "",
"ActivityType": "T005",
"WBSElement": "STLBSNL21042023.1.4",
"WorkItem": "P005",
"TimeSheetTaskType": "",
"TimeSheetTaskLevel": "",
"TimeSheetTaskComponent": "",
"TimeSheetNote": "",
"RecordedHours": "11",
"RecordedQuantity": "1",
"HoursUnitOfMeasure": "H",
"RejectionReason": "",
"TimeSheetWrkLocCode": "",
"TimeSheetOvertimeCategory": ""
},
"PersonWorkAgreementExternalID": "MOMPS03",
"CompanyCode": "1810",
"PersonWorkAgreement": null,
"TimeSheetDate": "2023-08-10T00:00:00",
"TimeSheetStatus": "30",
"TimeSheetIsExecutedInTestRun": false,
"TimeSheetOperation": "C"
}
It's working fine when we are posting the data in postman or API HUB.
Thanks
Request clarification before answering.
Make sure you have the csrf flag set in your package.json. Below an example for a MaintenanceNotification API
"OP_API_MAINTNOTIFICATION": {
"kind": "odata-v2",
"csrf": true,
"model": "srv/external/OP_API_MAINTNOTIFICATION",
"credentials": {
"destination": "abcde",
"path":"/sap/opu/odata/sap/API_MAINTNOTIFICATION"
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
9 | |
4 | |
3 | |
3 | |
3 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.