Skip to Content
0

SAP HANA trial receiving 502 server error authenticating to Success Factors API

Mar 08 at 05:42 PM

67

avatar image
Former Member

Hello,

I am a trial user developing a demo iOS app using SAP Cloud Platform SDK for iOS Assistant. Searching SAP API Business Hub for SF API, I was able to create several mobile native apps using connections/destinations to various SF API endpoints. Using the iOS Assistant specifying existing connections mostly work but I'm running into a reproducible 502 error after supplying onboarding credentials for one particular API. I let the assistant generate a master/detail app using the following connection:

Success Factors User Management (User, UserPermissions)

https://sandbox.api.sap.com/successfactors/odata/v2/User

The app is not using authentication only specifying APIKey in request header. I have successfully tested this API in Discovery API tools in browser as well as Postman and Curl so I know it works. The iOS Assistant is able to generate an Xcode project using a destination with the above URL. App compiles and executed on iOS Simulator while displaying the on-boarding and authentication screens. After entering correct credentials, the response returns with a 502 error stating authentication failed and to check authentication URL and authenticator used. To note, the destination/connector configuration is identical to others I have configured for additional endpoints and it is not clear in the logs why this one fails. Here is a screenshot of the error on iOS simulator.

Any help is appreciated.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
Andreas Schlosser
Mar 09 at 03:54 PM
0

Brian,I tried reproducing this with the Assistant and creating a new app with an SAP API Business Hub endpoint. I'm not seeing exactly the same thing, but also a failed onboarding flow because apparently the backend doesn't respond with a service catalog at the root URL. The problem is that the onboarding flow tries to connect to a backend URL to validate that the authentication was actually successful, and default to the service root - as you can see in your error message. What helped in my case was that I configured the OnboardingManager.swift in the generated app to use a different URL to validate the authentication

let discoveryConfigurationTransformer = DiscoveryServiceConfigurationTransformer(applicationID: "com.martiancraft.sap.user.mcorg", authenticationPath: "com.martiancraft.sap.user.mcorg")

try change this to

let discoveryConfigurationTransformer = DiscoveryServiceConfigurationTransformer(applicationID: "com.martiancraft.sap.user.mcorg", authenticationPath: "com.martiancraft.sap.user.mcorg/$metadata")

at least for me that did the trick

Thanks

Andreas

Show 2 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hi Andreas,

Thank you for getting back so quickly.

Your solution worked in that I got past the authentication and into the app. By appending "/$metadata" to the authenticationPath during instantiating the DiscoveryServiceConfigurationTransformer resolved the service root and got past the authentication.

However, I want to point out that it caused another downstream server error (501) immediately after authenticating which I was able to resolve by hacking the `configureOData(_ urlSession: SAPURLSession, _ serviceRoot: URL)` method in AppDelegate. Essentially, The "$metadata" path had to be removed from the serviceRoot during the instantiation of the OnlineODataProvider. Here is the method. You will notice the `deleteLastPathComponent()`

```

// MARK: - Configure OData

private func configureOData(_ urlSession: SAPURLSession, _ serviceRoot: URL) {

var newServiceRoot: URL = serviceRoot

newServiceRoot.deleteLastPathComponent()

let odataProvider = OnlineODataProvider(serviceName: "EntityContainer", serviceRoot: newServiceRoot, sapURLSession: urlSession)

// Disables version validation of the backend OData service

// TODO: Should only be used in demo and test applications

odataProvider.serviceOptions.checkVersion = false

self.entityContainer = EntityContainer(provider: odataProvider)

// To update entity force to use X-HTTP-Method header self.entityContainer.provider.networkOptions.tunneledMethods.append("MERGE")

}

```

0

Strange side effect - not sure why I didn't see this in my case. Anyways, looks for now you're good. Glad we got this to work for you

Andreas

0