0

I'm trying to update Dokan settings using REST API, but I get 404 when I use JWT Auth and I get 403 (Forbidden, auth header malformed) when I use basic auth, here's my code (Dart):

    var jwtToken = await getUserJWTToken(emailAddress, password);

    var bearerToken = 'Bearer $jwtToken';

    var basicAuth =
        'Basic ' + base64Encode(utf8.encode('$emailAddress:$password'));

    final response = await httpPut(
        Uri.parse('${rootUrl}wp-json/dokan/v1/settings'),
        headers: {
          'authorization': bearerToken,
          'cache-control': 'no-cache'
        },
        body: {
          'store_name': storeName,
          'phone': phoneNumber,
          'address': jsonEncode({
            'street_1': street1,
            'street_2': street2,
            'city': city,
            'zip': zip,
            'country': country,
            'state': state
          })
        });

what's wrong with this request.

Ahmed Nabil
  • 581
  • 1
  • 7
  • 26

1 Answers1

0

Because the update function does not exist:

go to file StoreSettingController.php in yoursite for dokan :

yourplay/wp-content/plugin/dokan-lite/includes/REST/StoreSettingController.php

enter image description here and replace it with this file:

https://github.com/HusamoBinAref/dokan-setting/blob/main/StoreSettingController.php

Note: function update in file is :

public function update_settings( $request ) {  
$vendor = $this->get_vendor();
if ( is_wp_error( $vendor ) ) {
    return $vendor;
}
 else
 {
$response = dokan()->vendor->update( $vendor->id,  $request);
return rest_ensure_response( $response );
}
}

good lock