Creation of Resources in Woocommerce

Asked

Viewed 14 times

0

Good afternoon,

I’m creating a flutter/Dart app and I’m not getting permission to create a new client. I’ve already modified . htaccess and everything. In my cPanel I have 5 domains and as I am working on the main one, the file . htaccess I modified was in /public_html/.htaccess. I’m also not sure which htaccess file to change.

Follow the code below:

  static String key = "consumer_key:ck_***************************";
  static String secret = "consumer_secret:cs_*****************************";
  static String url = "https://ut-bio.com/wp-json/wc/v3/";
  static String customerURL = "customers";
}
class APIService {
  Future<bool> createCustomer(CustomerModel model) async {
    var authToken = base64.encode(
      utf8.encode("?" + Config.key + "&" + Config.secret),
    );

    bool ret = false;

    try {
      var response = await Dio().post(Config.url + Config.customerURL,
          data: model.toJSON(),
          options: new Options(headers: {
            HttpHeaders.authorizationHeader: 'Basic $authToken',
            HttpHeaders.contentTypeHeader: "application/json"
          }));

      if (response.statusCode == 201) {
        ret = true;
      }
    } on DioError catch (e) {
      if (e.response!.statusCode == 404) {
        ret = false;
      } else
        ret = false;
    }
    return ret;
  }
}

File . htaccess

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>

Help is needed!!!

Thank you

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.