Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Android running net.sendRequest returns redirectOnLoad(); #358

Open
oktalk opened this issue Feb 29, 2024 · 2 comments
Open

Error: Android running net.sendRequest returns redirectOnLoad(); #358

oktalk opened this issue Feb 29, 2024 · 2 comments

Comments

@oktalk
Copy link

oktalk commented Feb 29, 2024

This issue is baffling me. My code works on iOS, but not on Android. In our React Native app, we are fetching v55.0/support/knowledgeArticles to get a list of articles.

Here is my code:

      net.sendRequest(
        '/services/data',
        'v55.0/support/knowledgeArticles?pageSize=5&categories=%7B%27Standard_Knowledge_Article%27%3A%27Featured_Articles%27%7D',
        (success) => {
          setFeaturedArticles(success.articles);
        },
        (error) => {
          console.log(error);
        },
        'GET',
      );

On iOS this is my return:

{
articles: [...],
currentPageUrl: '...',
nextPageUrl: null,
pageNumber: 1
}

However, on Android that same code returns this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
    <script>
        function redirectOnLoad() {
            if (this.SfdcApp && this.SfdcApp.projectOneNavigator) {
                SfdcApp.projectOneNavigator.handleRedirect('https://domain.sandbox.my.site.com/Domain/s/login?ec=302&startURL=%2FDomain%2Fservices%2Fdatav55.0%2Fsupport%2FknowledgeArticles');
            } else
                if (window.location.replace) {
                    window.location.replace('https://domain.sandbox.my.site.com/Domain/s/login?ec=302&startURL=%2FDomain%2Fservices%2Fdatav55.0%2Fsupport%2FknowledgeArticles');
                } else {
                    window.location.href = 'https://domain.sandbox.my.site.com/Domain/s/login?ec=302&startURL=%2FDomain%2Fservices%2Fdatav55.0%2Fsupport%2FknowledgeArticles';
                }
        }
        redirectOnLoad();
    </script>
</head>
</html>

Please help. Do I have a syntax error? Am I doing something I'm not supposed to be? Any help would be appreciated.

@oktalk
Copy link
Author

oktalk commented Feb 29, 2024

I should note, we are on SF mobile SDK v11.1.0

@wmathurin
Copy link
Contributor

That looks like an HTML error page for invalid session (API calls should not returned those).

Could you double check that the user has the appropriate perms, that the connected app has the required scopes, that the requested scopes by the client app match the scopes the connected app supports (check the boot config or your Android app)? Could you also if possible run it with the latest Mobile SDK (12.2) ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants