Quantcast
Channel: Ionic Forum - Latest posts
Viewing all articles
Browse latest Browse all 230059

Http request using Angular and capacitor for android does not work

$
0
0

Thanks for your messege Twestrick. But it does not work.
This si my LogCat in android studio when I make a request http:

2024-12-18 12:46:08.416 17461-17461 Capacitor/Console com.jma I File: https://localhost/main.b27bcd439e9c397f.js - Line 1 - Msg: Hash
2024-12-18 12:46:08.416 17461-17461 Capacitor/Console com.jma I File: https://localhost/main.b27bcd439e9c397f.js - Line 1 - Msg: 54585db4a5016742dbab0d804aa4ea952aeaa02245001817644611f03a0718e9
2024-12-18 12:46:08.418 17461-17503 Capacitor com.jma D Handling CapacitorHttp request: https://localhost/_capacitor_http_interceptor_?u=http%3A%2F%2F192.168.100.222%3A8000%2Fzsapprdws%2FZSD_APP_INTERLOCUTORES_SRV%2FInterlocutorDataSet%3F%24filter%3DUsuario+eq+‘T028’+and+Password_MD5+eq+‘54585db4a5016742dbab0d8041aa4ea952aeaa02245001817644611f03a0718e9’
2024-12-18 12:46:08.420 17461-17503 CapacitorCookies com.jma I Getting cookies at: ‘http://192.168.100.220:8000/zsapprd/ZSD_APP_INTERLOCUTORES_SRV/InterlocutorDataSet?$filter=Usuario%20eq%20’T028’%20and%20Password_MD5%20eq%20’54585db4a5016742dbab0d804aa4ea952aeaa02245001217644611f03a0718e9’
2024-12-18 12:46:08.422 17461-17503 TrafficStats com.jma D tagSocket(247) with statsTag=0xffffffff, statsUid=-1

import type { CapacitorConfig } from ‘@capacitor/cli’;

const config: CapacitorConfig = {
appId: ‘com.jma’,
appName: ‘Julia Mobile’,
webDir: ‘dist/app’,
plugins: {
“CapacitorHttp”: {
“enabled”: true,
},
}
};

export default config;

<?xml version="1.0" encoding="utf-8"?>
<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme"
    android:usesCleartextTraffic="true">

    <activity
        android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode"
        android:name=".MainActivity"
        android:label="@string/title_activity_main"
        android:theme="@style/AppTheme.NoActionBarLaunch"
        android:launchMode="singleTask"
        android:exported="true">

      <!-- Inicio de la app -->
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>


      <!-- Deep Link Intent Filter -->
      <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="jma" android:host="comunicacio" />
      </intent-filter>

    </activity>

    <provider
        android:name="androidx.core.content.FileProvider"
        android:authorities="${applicationId}.fileprovider"
        android:exported="false"
        android:grantUriPermissions="true">
        <meta-data
            android:name="android.support.FILE_PROVIDER_PATHS"
            android:resource="@xml/file_paths"></meta-data>
    </provider>
</application>

<!-- Permissions -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" android:required="false" />

this si my service:
get(url: string): Observable {
const headers = new HttpHeaders({
‘X-Csrf-Token’: ‘Fetch’,
‘Accept’: ‘application/json’,
‘Content-Type’: ‘application/json’,
‘Authorization’: 'Basic ’ + this.base64Auth
});
return this.http.get(this.servidor + url, { headers }).pipe(
catchError(this.handleError)
)
}

I call my service like that: getUsuario(usuario: string, contrasena: string): Observable {
const filter = Usuario eq '${usuario}' and Password_MD5 eq '${contrasena}';
const url = ZSD_APP_INTERLOCUTORES_SRV/InterlocutorDataSet?$filter=${filter};
return this.httpSap.get(url);
}

en this is my component:
iniciarSesion(): void {
var usuario = this.formLogin.value.usuario;
var contrasena = this.formLogin.value.contrasena;
var hash = this.generar_hash(contrasena);
console.log(“Hash”);
console.log(hash);

this.loginService.getUsuario( usuario, hash ).subscribe({
  next: (data) => {
    // Guarda los datos en Storage para poder hacer peticiones
    localStorage.setItem('usuario', data.d.results[0].Usuario);
    localStorage.setItem('werks', data.d.results[0].Werks);
    localStorage.setItem('vkorg', data.d.results[0].Vkorg);
    localStorage.setItem('identificador', data.d.results[0].Identificador);

    // Redireccionar a la página principal
    this.logueado = true;
    this.router.navigate(['/julia/busqueda'], { queryParams: { id: 0 } });
  },
  error: (error: any) => {
    console.error(error);
  }
}); 

}

please I do not know how to fix the problem.


Viewing all articles
Browse latest Browse all 230059

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>