Tried calling HTTP.post, but the HTTP plugin is not installed

I’m trying to do a rather simple HTTP post with some JSON data on my Android device using the native HTTP plugin but I’m getting the following error:

pages/test-network/test-network.ts

import { HTTP } from '@ionic-native/http';
import { Component } from '@angular/core';
import { NavController, NavParams, IonicPage } from 'ionic-angular';
import { Hotspot } from '@ionic-native/hotspot';

@IonicPage()
@Component({
  selector: 'page-test-network',
  templateUrl: 'test-network.html',
})
export class TestNetworkPage {

  constructor(public navCtrl: NavController,
    public navParams: NavParams,
    public Hotspot: Hotspot,
    public http: HTTP) {
  }

  ionViewDidLoad() {
    console.log('ionViewDidLoad TestNetworkPage');
  }

  ...snip...

  postLanmap(url: string, lanmap: any) {
    this.http.post(url, lanmap, {})
      .then(response => {
        console.log("test-network: got response: " + response);
      }).catch(err => {
        console.log("test-network: got error: " + err);
      });

    this.navCtrl.push('CurrentNetworkPage', {});
  }
}

error

Native: tried calling HTTP.post, but the HTTP plugin is not installed.
Install the HTTP plugin: 'ionic cordova plugin add cordova-plugin-advanced-http'

Here’s a confirmation that the plugin is indeed installed:

daniel:~/hl-mobile$ ionic cordova plugin add cordova-plugin-advanced-http
> cordova plugin add cordova-plugin-advanced-http --save
✔ Running command - done!
Plugin "cordova-plugin-advanced-http" already installed on android.
Adding cordova-plugin-advanced-http to package.json
Saved plugin info for "cordova-plugin-advanced-http" to config.xml

daniel:~/hl-mobile$ sudo npm install --save @ionic-native/http
+ @ionic-native/http@4.2.1
updated 1 package in 7.349s

Any idea what’s going on?

See https://github.com/ionic-team/ionic-native/issues/1975

The issue appears to have been fixed but there might be a lag in updating npm

1 Like

Yup, that seems to fix it! Weird that I didn’t stumble across that Googling. Thanks!

Hello
Has thsi been fixed.
I’m still getting the error
Ta
JC

This appears to be rearing its ugly head again. I’m using plugin version 2.1.1 and here is my ionic info:

Ionic:

   ionic (Ionic CLI)             : 4.12.0
   Ionic Framework               : @ionic/angular 4.2.0
   @angular-devkit/build-angular : 0.13.9
   @angular-devkit/schematics    : 7.3.9
   @angular/cli                  : 7.3.9
   @ionic/angular-toolkit        : 1.5.1

Cordova:

   cordova (Cordova CLI) : 8.1.2 (cordova-lib@8.1.1)
   Cordova Platforms     : android 8.0.0
   Cordova Plugins       : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 4.0.1, (and 29 other plugins)

System:

   Android SDK Tools : 26.1.1 (/Users/rc101077/Library/Android/sdk)
   ios-sim           : 8.0.1
   NodeJS            : v10.16.0 (/Users/rc101077/.nvm/versions/node/v10.16.0/bin/node)
   npm               : 6.9.0
   OS                : macOS Mojave
   Xcode             : Xcode 10.2.1 Build version 10E1001

I’m using SSL pinning as well, but even when I disable that, I get the same error.