IONIC call webservice token

http status 200 is Success!..

but the second one is that the returned data (if any) is not json format, but XML…
so maybe you have to add another parm or header to get json response.

i hate these libraries that jam everything together, and when there is an error its reported in the wrong place.

i get no error but no status either.I think things got worse…
Please why is this so hard to achieve a Http response?

https://github.com/NikolaosBenakis/HttpRequest-to-WebService-Api-with-Parameters/tree/master/src

Above link contain my whole src code.
I coded —> pages/home/Home.ts
providers/loginservice/loginservice.ts

import { Component } from ‘@angular/core’;
import { NavController } from ‘ionic-angular’;
import {LoginserviceProvider} from “…/…/providers/loginservice/loginservice”;

@Component({
selector: ‘page-home’,
templateUrl: ‘home.html’
})
export class HomePage {
params:{
SubscriptionPassword: string;
UserID: string;
UserPassword: string;
BranchID: string;
AllowHttp: boolean;
};

constructor(public navCtrl: NavController,
private loginserviceprovider: LoginserviceProvider) {
}

ionWillEnter() {
let url = ‘http://192.168.0.6:81/EBSWebApi’;
this.params = {
SubscriptionPassword: “passx”,
UserID: “khcadmin”,
UserPassword: “00100100957”,
BranchID: “01”,
AllowHttp: true
};
let options = {};

this.loginserviceprovider.getResponse(url,this.params,options)
.subscribe(data=>{
console.log(data);
});
}
}

import { HttpClient } from ‘@angular/common/http’;
import { Injectable } from ‘@angular/core’;
import ‘rxjs/add/operator/map’;
import {Observable} from “rxjs/Observable”;

@Injectable()
export class LoginserviceProvider {

url;

params ={ SubscriptionPassword: “passx”,
UserID: “khcadmin”,
UserPassword: “00100100957”,
BranchID: “01”,
AllowHttp: true
};
constructor(public http: HttpClient) {
console.log(‘Hello LoginserviceProvider Provider’);
this.url =“http://192.168.0.6:81/EBSWebApi”;
}

public getResponse(url:string,params?:any, options:any ={}):Observable{
// options.params =this.params;
// options.withCredentials=true;
return this.http.get(this.url+params+options);

}
}

shouldn’t that be

return this.http.get(this.url,params,options);

i don’t know your api, but typically you tell the server that you want JSON response via a header

et url = ‘http://192.168.0.6:81/EBSWebApi’;
this.params = {
SubscriptionPassword: “passx”,
UserID: “khcadmin”,
UserPassword: “00100100957”,
BranchID: “01”,
AllowHttp: true
};
let options = {Accept:'application/json'};
this.loginserviceprovider.getResponse(url,this.params,options)

.get or .post?
because i need to set my parameters in order to get the authentication key.
I think there is my issue
My webservice needs some credentials in order to generate a authentication token.
and i want to set my params to the webservice and console log the token!
that’s my goal

sorry, without knowing your api design I can’t get more specific.

you should write down what the flow is to make the api work

what info you need to send, what you get back, in what order

then once u understand that, you can write code to match

The thing is that I have the code in AngularJS that works with this api.
But i cant do the translate.I write down the .html file and the .js file .

<title>Demo ESWebApi Calls</title>
<script src="Scripts/libs/jquery/jquery-1.11.2.min.js"></script>
<script src="Scripts/libs/jquery-ui/jquery-ui-1.11.2.js"></script>
<script src="scripts/ModelViewJS.js"></script>

--- Call Web API TEST GEM1---

    </table>
    <div>
        <h4>--- Info Result details ---</h4>
        <h4>Auth Web API Token:</h4>
        <p id="token"></p>
        <p>-----</p>
        
    </div>
</div>

/*
Following are the variables required to connect with WebAPI.
You need to modify them accordingly. Yu don;t need to change the token variable, since it will be updated by the login call.

-- variables description --
webapihost: the http(s) address of the WbAPI server
scrollerid: The scroller ID (used as an example in our case)
commandid: The automation ID (used as an example in our case)
token: The authentination Web API token returned by the call to the Login API

*/

var webapihost = “http://79.129.114.69:81/ebswebapi/”;
var scrollerid = “ESWBCat/WEBAPI_Pelatis”; // For our example, the View (scroller) ID that will be called
var commandid = “CreateUpdateCustomer”; // For our example, the Automation Command ID that will be called
var mastertableid = “ESFITradeAccount”;
var token = “”;

/*********** DEMO ************/

$(document).ready(function () {

/*
      Call login API
*/
$.ajax({
    url: webapihost + "api/login",
    type: "POST",
    data: JSON.stringify({
        /*
         Following are the Credentials required to connect to the WebAPI server. Valiable model contains the credensial as they would be entered by an EBS user 
        */
        SubscriptionPassword: 'passx', 
        model: {
            BranchID: "01",
            LangID: "el-GR",
            UserID: "khcadmin",
            Password: "P@ssw0rd"
        }
    }),
    contentType: "application/json; charset=utf-8",
    success: function (result) {

        token = result.Model.WebApiToken;
        document.getElementById("token").innerText = token;

        /*

After successfull loging in you may process with thw other calls, you have a valid token and you may proceed with other calls.
*/
GetUpdatePersonData(token);
},
error: function (error) {
document.getElementById(“token”).innerText = “error:” + JSON.stringify(error);
console.log(“error:” + JSON.stringify(error));
}

});

});

Scroller (folder/scrollerName): ESWBCat/WEBAPI_Pelatis
Command id: CreateUpdateCustomer
MasterTable: ESFITradeAccount

ok, its really exactly the same

    url: webapihost + "api/login",
    type: "POST",
    data: JSON.stringify({
        /*
         Following are the Credentials required to connect to the WebAPI server. Valiable model contains the credensial as they would be entered by an EBS user 
        */
        SubscriptionPassword: 'passx', 
        model: {
            BranchID: "01",
            LangID: "el-GR",
            UserID: "khcadmin",
            Password: "P@ssw0rd"
        }
    }),
    contentType: "application/json; charset=utf-8",

becomes

url=webapihost + "api/login";
authorization_data=
        /*
         Following are the Credentials required to connect to the WebAPI server. Valiable model contains the credensial as they would be entered by an EBS user 
        */
        {
        SubscriptionPassword: 'passx', 
        model: {
            BranchID: "01",
            LangID: "el-GR",
            UserID: "khcadmin",
            Password: "P@ssw0rd"
        }
       };

options={contentType:"application/json; charset=utf-8"}
return this.http.post(url, authorization_data, options);

on return you get an xml document with the token in it

token = result.Model.WebApiToken;
        document.getElementById("token").innerText = token;