Piyush Gandhi
Piyush Gandhi

Reputation: 31

Unable to fetch the metadata : Failed to execute OData Metadata request

I am trying to read data from S4hana cloud. I configured the destination in cloud foundry where authentication type is OAuth2SAMLBearerAssertion.

and I wrote a little servlet also to get the data using VDM mechanism.

But I am getting below error when I am calling the endpoint

 Caused by: com.sap.cloud.sdk.cloudplatform.connectivity.TokenRequestFailedException: Failed to get access token: no valid JWT bearer found in "Authorization" header of request.
   2018-10-09T15:34:52.84+0530 [APP/PROC/WEB/0] OUT     at com.sap.cloud.sdk.cloudplatform.connectivity.TokenRequest.getCurrentJwt(TokenRequest.java:308)
   2018-10-09T15:34:52.84+0530 [APP/PROC/WEB/0] OUT     at com.sap.cloud.sdk.cloudplatform.connectivity.TokenRequest.requestTokenWithUserTokenGrant(TokenRequest.java:352)
   2018-10-09T15:34:52.84+0530 [APP/PROC/WEB/0] OUT     at com.sap.cloud.sdk.cloudplatform.connectivity.XsuaaService.requestAccessToken(XsuaaService.java:135)
   2018-10-09T15:34:52.84+0530 [APP/PROC/WEB/0] OUT     at com.sap.cloud.sdk.cloudplatform.connectivity.XsuaaService.getServiceToken(XsuaaService.java:197)
   2018-10-09T15:34:52.84+0530 [APP/PROC/WEB/0] OUT     at com.sap.cloud.sdk.cloudplatform.connectivity.DestinationServiceCommand.getAccessToken(DestinationServiceCommand.java:109)
   2018-10-09T15:34:52.84+0530 [APP/PROC/WEB/0] OUT     ... 31 common frames omitted

I have followed https://blogs.sap.com/2018/02/05/deep-dive-8-with-sap-s4hana-cloud-sdk-leverage-principal-propagation-via-oauth-2-when-consuming-a-business-api-from-s4hana-cloud/.

Upvotes: 3

Views: 1175

Answers (1)

Sander Wozniak
Sander Wozniak

Reputation: 650

Have you setup security / configured an approuter?

The error message indicates a missing JWT in the request.

See also: https://blogs.sap.com/2017/07/18/step-7-with-sap-s4hana-cloud-sdk-secure-your-application-on-sap-cloud-platform-cloudfoundry/

Upvotes: 1

Related Questions