API POST request giving 0 as status code

Hi @Marcroni

I think it would be difficult for you to test on your side as you would have to have a SAP S/4Hana cloud system to test on and I cant give you the system details that I’m using but I’ll give you everything I am doing just with the sensitive data scratched out.

Ok so first I’m using the HTTP GET request to get the CSRF token.


My endpoint/api is (the system numbers in the api was replaced with X’s):

https://myXXXXXX-api.s4hana.ondemand.com/sap/opu/odata/sap/API_MANAGE_WORKFORCE_TIMESHEET/TimeSheetEntryCollection?%24top=1

This is my Header in the GET request:

I am using simple authentication. In the response that I get back extract the CSRF token and the cookie which will look like this:

p1dpQCx37SwQk8DOMmZdtw==

sap-usercontext=sap-client=100; path=/,SAP_SESSIONID_EH0_100=m3guEI9P-WGc7k2JIoAynOT7AEfT0xHpkz4AFj42_7s%3d; path=/; secure; HttpOnly

These values change after each GET request.

I am then adding the CSRF token and the cookie at headers in the HTTP POST request as follows:


My payload body is exactly this:
“{”“TimeSheetDataFields”“:{”“WBSElement”“:”“SAPPSC400099.1.4"”,““TimeSheetNote””:““API Note””,““RecordedHours””:““4"”,”“ActivityType”“:”“T002"”},““PersonWorkAgreementExternalID””:““AKURUKKAL””,““CompanyCode””:““D010"”,”“TimeSheetDate”“:”“/Date(1568015136000)/”“,”“TimeSheetStatus”“:”“20"”,““TimeSheetOperation””:““C””}"

If you want you can do a get to this specific API on the SAP API hub to their sanbox system, here is the link:
https://api.sap.com/api/API_MANAGE_WORKFORCE_TIMESHEET/resource

Note you wont be able to do a post to the sanbox system.

Please let me know if you need more info? Thanks for the help so far.

Regards
PF