cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

SAP Cloud SDK executeHttpRequest Request failed with status code 407

WouterLemaire
SAP Mentor
SAP Mentor
43,062

Hi all,

I'm trying to use the function "executeHttpRequest" of the cloud SDK to create a request to my on premise backend system like this:

const token = retrieveJwt(request);
return await executeHttpRequest({destinationName:"MyDestination",jwt:token},request)

Unfortunately this results in a 407, which means my proxy authentication is missing. But when I get my destination before sending the request, I notice that the proxy authentication is available. I do this by using the following function:

const destination = await getDestinationFromDestinationService("MyDestination",{userJwt:token})

Any idea what I'm missing?

Here you have the full log from the request till the 407 error:

2020-08-12T05:25:21.194+0000 [APP/PROC/WEB/0] OUT {"message":"Attempting to retrieve destination from destination service.","level":"info","custom_fields":{"package":"core","messageContext":"destination-accessor"},"logger":"sap-cloud-sdk-logger","timestamp":"2020-08-12T05:25:21.194Z","msg":"Attempting to retrieve destination from destination service.","written_ts":1597209921194,"written_at":"2020-08-12T05:25:21.194Z"}
2020-08-12T05:25:21.195+0000 [APP/PROC/WEB/0] OUT {"message":"Unable to match a specific XSUAA service instance to the given JWT. The following XSUAA instances are bound: cloud-approuter!t44784. The following one will be selected: cloud-approuter!t44784. This might produce errors in other parts of the system!","level":"warn","custom_fields":{"package":"core","messageContext":"environment-accessor"},"logger":"sap-cloud-sdk-logger","timestamp":"2020-08-12T05:25:21.195Z","msg":"Unable to match a specific XSUAA service instance to the given JWT. The following XSUAA instances are bound: cloud-approuter!t44784. The following one will be selected: cloud-approuter!t44784. This might produce errors in other parts of the system!","written_ts":1597209921195,"written_at":"2020-08-12T05:25:21.195Z"}
2020-08-12T05:25:21.438+0000 [APP/PROC/WEB/0] OUT {"message":"Successfully retrieved destination from destination service.","level":"info","custom_fields":{"package":"core","messageContext":"destination-accessor"},"logger":"sap-cloud-sdk-logger","timestamp":"2020-08-12T05:25:21.437Z","msg":"Successfully retrieved destination from destination service.","written_ts":1597209921437,"written_at":"2020-08-12T05:25:21.437Z"}
2020-08-12T05:25:21.438+0000 [APP/PROC/WEB/0] OUT {"message":"OnPrem destination proxy settings from connectivity service will be used.","level":"info","custom_fields":{"package":"core","messageContext":"proxy-util"},"logger":"sap-cloud-sdk-logger","timestamp":"2020-08-12T05:25:21.438Z","msg":"OnPrem destination proxy settings from connectivity service will be used.","written_ts":1597209921438,"written_at":"2020-08-12T05:25:21.438Z"}
2020-08-12T05:25:21.589+0000 [APP/PROC/WEB/0] OUT {"message":"OnPrem destination proxy settings from connectivity service will be used.","level":"info","custom_fields":{"package":"core","messageContext":"proxy-util"},"logger":"sap-cloud-sdk-logger","timestamp":"2020-08-12T05:25:21.588Z","msg":"OnPrem destination proxy settings from connectivity service will be used.","written_ts":1597209921588,"written_at":"2020-08-12T05:25:21.588Z"}
78XtjpPvNIvZGWQy2ToJhGpdF9fDZe5QDm3mVz_u_fLcFp42a417sGfCyY7UwS2faNL7PqZwH5amOsfzRZYkrLVixUk-TF6N1o6Xzv-4tPDOFD8fzV9Z6ItGzi3EOr5ZXfn_y2QBHNAMJOou6Atrr-7x4Lb3z8d6YI7eKAjAdQgMZgWQ-KjTol6a9f2CEQExwCNZNQ7GFUxIAav4xhDFjUMEQ' } } }
2020-08-12T05:25:21.706+0000 [APP/PROC/WEB/0] OUT [Nest] 81   - 08/12/2020, 5:25:21 AM   [ExceptionsHandler] Request failed with status code 407 +661ms
2020-08-12T05:25:21.706+0000 [APP/PROC/WEB/0] OUT Error: Request failed with status code 407
2020-08-12T05:25:21.706+0000 [APP/PROC/WEB/0] OUT     at createError (/home/vcap/deps/0/node_modules/axios/lib/core/createError.js:16:15)
2020-08-12T05:25:21.706+0000 [APP/PROC/WEB/0] OUT     at settle (/home/vcap/deps/0/node_modules/axios/lib/core/settle.js:17:12)
2020-08-12T05:25:21.706+0000 [APP/PROC/WEB/0] OUT     at IncomingMessage.handleStreamEnd (/home/vcap/deps/0/node_modules/axios/lib/adapters/http.js:236:11)
2020-08-12T05:25:21.706+0000 [APP/PROC/WEB/0] OUT     at IncomingMessage.emit (events.js:203:15)
2020-08-12T05:25:21.706+0000 [APP/PROC/WEB/0] OUT     at endReadableNT (_stream_readable.js:1145:12)
2020-08-12T05:25:21.706+0000 [APP/PROC/WEB/0] OUT     at process._tickCallback (internal/process/next_tick.js:63:19)

I'm also wondering why this shows up in the log "Unable to match a specific XSUAA service instance to the given JWT...." When looking at the decoded token and comparing it with the bound xsuaa service, it looks the same..

Thank you in advance!

View Entire Topic
frank_essenberger1
Product and Topic Expert
Product and Topic Expert
0 Likes

Could you send me the destination object you receive from the getDestinationFromService with any security relevant data replace with some dummy value.

WouterLemaire
SAP Mentor
SAP Mentor
0 Likes

Here you go:

{ originalProperties:
   { Name: 'destinationname',
     Type: 'HTTP',
     URL:
      'http://virtual-host:virtual-port/sap/opu/odata/sap/ZSERVICE/',
     Authentication: 'BasicAuthentication',
     ProxyType: 'OnPremise',
     'HTML5.ConnectionTimeoutInSeconds': '120',
     Description: 'My destination',
     User: 'User',
     'HTML5.SocketReadTimeoutInSeconds': '300',
     WebIDEEnabled: 'true',
     WebIDESystem: 'Systid',
     WebIDEUsage:
      'odata_abap, dev_abap,ui5_execute_abap, bsp_execute_abap,odata_gen',
     Password: 'password' },
  authTokens: [],
  certificates: [],
  name: 'destinationname',
  type: 'HTTP',
  url:
   'http:///virtual-host:virtual-port/sap/opu/odata/sap/ZSERVICE/',
  authentication: 'BasicAuthentication',
  proxyType: 'OnPremise',
  username: 'user',
  password: 'password',
  isTrustingAllCertificates: false,
  proxyConfiguration:
   { host: 'connectivityproxy.internal.cf.eu10.hana.ondemand.com',
     port: '20003',
     protocol: 'http',
     headers:
      { 'Proxy-Authorization':
         'Bearer eyJhbGciOiJSUzI1NiIsImprdSI6Imh0dHBzOi8vY2ZjcGVhZXh0Y29udHJhY2F1dGhwaWx...',
        'SAP-Connectivity-Authentication':
         'Bearer eyJhbGciOiJSUzI1NiIsImprdSI6Imh0dHBzOi8vY2ZjcGVhZXh0Y29udHJhY2F1dGhwaWxvdC5hdXRoZW50aWNhdGlvb...' } } }


<br>