sap-tutorials / Tutorials

Tutorials on sap.com
https://developers.sap.com/tutorial-navigator.html
Creative Commons Attribution 4.0 International
732 stars 778 forks source link

Connect to OData Service on Cloud Foundry Using SAP Cloud SDK #4453

Closed agl-phenr closed 4 years ago

agl-phenr commented 4 years ago

Tutorial URL: https://developers.sap.com/tutorials/s4sdk-odata-service-cloud-foundry.html

Please specify the step you are referring to 10: Systems.json and credentials.

Hi gurus,

I managed to run the test class and get results. Failure has happened on status code (<404> instead of <200>). I reviewed the systems.yml and play around with fields systemId, sapClient, but got no luck. I´ve tried already both fields systemId and sapClient = blank, however, I keep getting 404.

Find enclosed my project. simpleCFApp - Copy.zip

BR, Pietro

MatKuhr commented 4 years ago

Hi, to pinpoint the issue please consider the following querstions:

agl-phenr commented 4 years ago

Hi @MatKuhr,

My comments down below:

Are you running your tests locally? Pietro: No. I am connecting to an S/4HC

Are you certain you provided the correct details for your S/4 system in the systems.yml and it is placed in the appropriate directoy? Pietro: Yes, I do. I can assure you on URL, what was used successfully in step07. However, I am not sure of systemId and sapClient as I am using S/4HC, thus I cannot retrieve such information. Also, I´ve tried using sapClient and systemId = blank. The file systems.yml is in "/integration-tests/src/test/resources

Do you target a cloud S/4 instance or on premise? Pietro: S/4Hana Cloud Public (instance: https://my302085-api.s4hana.ondemand.com)

BR, Pietro

MatKuhr commented 4 years ago

Are you running your tests locally? Pietro: No. I am connecting to an S/4HC

I was actually asking if you are executing the test class introduced in step 8 on your local machine. This is different from running the code on Cloud Foundry or a locally setup server instance.

In general, for S4HC you can remove the optional lines including system ID and sap client.

Pietro: Yes, I do. I can assure you on URL, what was used successfully in step07.

Step 7 does not contain any instructions to execute tests. Do you mean step 8? Please specify a little bit more at which point exactly the problem is occurring.

agl-phenr commented 4 years ago

Hi @MatKuhr,

Sorry, I misunderstood the question. Yes, I am running it locally (step 08 of the tutorial). Also, I removed optional lines and tried both instances ( https://my302085.s4hana.ondemand.com and https://my302085-api.s4hana.ondemand.com). Unfortunately, the issue kept.

As for my quote " Pietro: Yes, I do. I can assure you on URL, what was used successfully in step07.", my bad again. I meant I got no issue by using such instance and credentials on step 05 (servlet) and 06 (deployment of servlet connecting to S4HC).

I attach my project up to date (after the changes stated out above)

simpleCFApp - Copy2.zip

BR, Pietro

MatKuhr commented 4 years ago

Hi Pietro,

after some investigation this again turned out to be a copy and paste error. Note that in your test code you are deploying the wrong servlet for testing.

Instead of:

return TestUtil.createDeployment(HelloWorldServlet.class);

please use:

return TestUtil.createDeployment(BusinessPartnerServlet.class);

The HelloWorldServlet of course has no endpoint /businesspartners so it returns a 404.

agl-phenr commented 4 years ago

Hi @MatKuhr,

First of all, the correction proposed (which was a mistyping from my end) did solve the issue. Thus, I close the issue.

Other than that, my apologies for such a silly issue. My way of absorbing it by retyping the code. Anyway, from now, I will make sure I reviewed my code type carefully before I raise a new ticket.

That said, thank you again, and I wish you a good one.

BR, Pietro

MatKuhr commented 4 years ago

No problem, I am glad that solved it for you 👍