0

Using the SAP V2 Code Generator we have created classes for Success Factors.

When generating a URL for a request that invokes an Navigated Entity it throws a 500 error.

PerPersonFluentHelper q = service.getAllPerPerson().select(PerPerson.TO_EMAIL_NAV);

generates $select=emailNav/*&$expand=emailNav

Trying to run that results in

message lang="en-US">Unable to understand API request with character sequence: emailNav/* at character position number: 9 invalid characters: *

I get a similar problem when/if I try to use the ALL_FIELDS static field for an entity.

If I remove the /* and paste the url into a browser it works fine.

We are looking for any solutions. Have already spent days reading blogs and running searches.

Is there an advanced documentation on the use of the generated classes?

Thanks in advance.

FOUND A SOLUTION -- Found a away around the problem by cloning the FluentHelperBasic class and doing the following:

for (int i = 0; i < selections.size(); i++) {
        String select = selections.get(i);
        if (select.endsWith("/*")) {
            selections.set(i, select.substring(0,select.length()-2));
        }
    }
fieldNames.addAll(selections);
selections.forEach(delegateSelect);

this code needs to be moved AFTER the code setting delegate expansion.

1 Answers1

0

Unfortunately SFSF does not accept the * as a selector for all fields. You can work around this by declaring all fields of the property to be expanded in the select clause:

select(PerPerson.TO_EMAIL_NAV.select(Email.FIELD_1, Email.FIELD_2));
MatKuhr
  • 505
  • 4
  • 13
  • unfortunate - makes you wonder why the code generator generates a URL which it cannot run. You would think it works someplace. – Bob Fleischman Mar 19 '21 at 15:31
  • Most OData services interpret the `*` correctly, e.g. OData Services on S/4HANA and S/4HANA Cloud. SuccessFactors is the exception here AFAIK. – MatKuhr Mar 20 '21 at 09:47
  • I just noticed that if I remove the /* from the URL it returns the correct results. Is the source code for the Code Generator available? – Bob Fleischman Mar 23 '21 at 15:06
  • At the moment the Java SDK is not open source, so no it is not available. But even if it were the `/*` is added by the implementation of `select`, it is not coming from generated code. So currently there is no way to alter the behaviour. – MatKuhr Mar 24 '21 at 10:56
  • Please see my edited original post. I found a way to clone the FluentHelperBasic class and modify it to correct the URl. It now works for our purposes. – Bob Fleischman Mar 24 '21 at 15:41
  • By "clone" you mean extending via inheritance? Please note that this will only work if you are using `execute(..)` to run the request, which is deprecated. The recommended `executeRequest(..)` will not work in the same way. – MatKuhr Mar 25 '21 at 10:48