Data Requests

After you complete the registration and initialize the secure store, you can request data from the back end.

Application developers can get information about the registration data with this MAF Logon Integration API call:
NSError* localError = nil;
MAFLogonRegistrationData* data = [self.logonManager registrationDataWithError:&localError];

if (localError) {
    //handle error
} else {
    //access registration data, like:
    self.communicatorId = data.communicatorId;
    self.appEndpoint = data.applicationEndpointURL;
}
Create a request object. Set the request object’s properties based on the content of MAFLogonRegistrationData:
/*
 * returns an Request instance for the url
 */
-(id<Requesting>) requestWithURL:(NSURL *) url withMethodType:(NSString *)methodType{
    id<Requesting> request = nil;
    
    //getting the request object from SMP OData client library.
    request = [RequestBuilder requestWithURL:url];
    
    [request setUsername:self.registrationData.backendUserName];
    [request setPassword:self.registrationData.backendPassword];
    
    [request setRequestMethod:methodType];
    if([self.registrationData.communicatorId isEqualToString:idMAFLogonCommunicator_SMPHTTPREST]){
        [request addRequestHeader:@"X-SUP-APPCID" value:self.registrationData.applicationConnectionId];
        [request addRequestHeader:@"X-SMP-APPCID" value:self.registrationData.applicationConnectionId];
} 
    return request;
}

You must add the X-SUP-APPCID and X-SMP-APPCID headers to the request if the communicatorId property is idMAFLogonCommunicator_SMPHTTPREST, otherwise the the SAP Mobile Platform server rejects the request.

Initialize the URL passed to the above method according to the registration type chosen by MAF Logon. The MAFLogonRegistrationData object contains the applicationEnpointURL property. Use this property as-is to initialize the URL object in all registration types, except the Direct Gateway. When you log on to a Gateway system directly, MAF uses the Gateway ping URL to verify the connection instead of the Gateway content. If the request to the Gateway ping URL succeeds, the logon succeeds. Therefore, if the communicatorId is idMAFLogonCommunicator_GatewayOnly, the application needs to store the unique Gateway content URL suffix and concatenate it after the applicationEndpointURL property value:
NSString* fullEndpoint = self.applicationEndpoint;
    if([self.communicatorId isEqualToString:idMAFLogonCommunicator_GatewayOnly]){
        NSString* serviceDocumentFormat = @"";
        if([fullEndpoint hasSuffix:@"/"]){
            serviceDocumentFormat = @"sap/opu/odata/GBHCM/LEAVEREQUEST/";
        }
        else{
            serviceDocumentFormat = @"/sap/opu/odata/GBHCM/LEAVEREQUEST/";
        }
        
        fullEndpoint = [fullEndpoint stringByAppendingString:serviceDocumentFormat];
        self.applicationEndpoint = fullEndpoint;
    }