Open Closed

API call failing from react Native Application. #2893


User avatar
0
PravinRaijade created

Check the docs before asking a question: https://docs.abp.io/en/commercial/latest/ Check the samples, to see the basic tasks: https://docs.abp.io/en/commercial/latest/samples/index The exact solution to your question may have been answered before, please use the search on the homepage.

If you're creating a bug/problem report, please include followings:

  • ABP Framework version: v4.3.3
  • UI type: / MVC /
  • DB provider: EF Core /
  • Tiered (MVC) or Identity Server Separated (Angular): no
  • Exception message and stack trace:
  • Steps to reproduce the issue:"

Hi Support,

Facing issues while calling API deployed on remote server from react-native client. After deploying Web Application on remote cloud VM (running Windows Server ), API calls are failing from react native client. However, they are working when called from swagger.

  1. Getting user Token successfully with below code, var token; await axiosInstance({ method: 'POST', url: '/connect/token', headers: {'Content-Type': 'application/x-www-form-urlencoded'}, data: `grant_type=password&scope=${oAuthConfig.scope}&username=${localUserName}&password=${localPassword}&client_id=${oAuthConfig.clientId}&client_secret=${oAuthConfig.clientSecret}&__tenant=${localTenantId}`, baseURL: oAuthConfig.issuer, }) .then(({data}) => { token = data; console.log('Token from Get Tenant ID Success'); }) .catch(error => { console.log('token from get Tenant Id failed'); Alert.alert('Error', 'Getting Token Failed for Tenant-Id '); });

  2. Below request to get Tenant by name failing,

await axiosInstance({ method: 'GET', baseURL: oAuthConfig.issuer, url: `/api/abp/multi-tenancy/tenants/by-name/${localTenantName}`, headers: { 'Content-Type': 'application/json', __tenant: `${localTenantId}`, Authorization: `${token.token_type} ${token.access_token}`, }, })

localTenantId is '' (null) for host.

Note: a) It works when running on local machine with IIS express in development environment. Mobile App is able to call API successfully.

Appreciate quick turnaround. we have demo to senior management.

Regards, Pravin Raijade.


1 Answer(s)
  • User Avatar
    0
    EngincanV created
    Support Team .NET Developer

    Hi, can you check your production environment settings are correct or not?

    You can open the Environment.js and check the prod section. Please, ensure your apiUrl and issuer is correct and point to the backend server on production.

Made with ❤️ on ABP v9.1.0-preview. Updated on December 05, 2024, 12:19