Title: REST API Error
Last modified: February 11, 2023

---

# REST API Error

 *  Resolved [Alex@portalZINE](https://wordpress.org/support/users/portalzine/)
 * (@portalzine)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/rest-api-error-36/)
 * REST API breaks for me as the format function is missing:
 * Call to undefined method stdClass::format_value_for_rest()
 * Cheers
   Alexander

Viewing 10 replies - 1 through 10 (of 10 total)

 *  Plugin Author [Matt Keys](https://wordpress.org/support/users/mattkeys/)
 * (@mattkeys)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/rest-api-error-36/#post-16462096)
 * Hmm, I’ve never tried using this in REST. This was originally built before WP&
   REST was really a thing so probably a blind spot that just hasn’t been brought
   up by other users yet. Looking at the [latest boilerplate for new ACF fields](https://github.com/AdvancedCustomFields/acf-example-field-type/blob/main/acf-FIELD-NAME/class-PREFIX-acf-field-FIELD-NAME.php)
   I don’t see any mention of the format_value_for_rest() function you are seeing
   errors about. I don’t extend that function in my plugin but you’d think it would
   be able to access it from the parent ‘acf_field’ class my field extends.
 *     ```wp-block-code
       /**
        * Apply basic formatting to prepare the value for default REST output.
        *
        * @param mixed      $value
        * @param string|int $post_id
        * @param array      $field
        * @return mixed
        */
       public function format_value_for_rest( $value, $post_id, array $field ) {
       	return $value;
       }
       ```
   
    -  This reply was modified 3 years, 4 months ago by [Matt Keys](https://wordpress.org/support/users/mattkeys/).
 *  Plugin Author [Matt Keys](https://wordpress.org/support/users/mattkeys/)
 * (@mattkeys)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/rest-api-error-36/#post-16462119)
 * Does adding `public $show_in_rest = true;` to the class in either `acf-font-awesome-
   v5.php` or `acf-font-awesome-v6.php` (depending which FontAwesome you are using)
   make any difference to the error you are seeing?
 * See the boilerplate I linked above for where they added that line.
 *  Thread Starter [Alex@portalZINE](https://wordpress.org/support/users/portalzine/)
 * (@portalzine)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/rest-api-error-36/#post-16462167)
 * `public $show_in_rest = true;` does not fix the error. 
   Seems to be related to
   the fieldtype not being reported at all.
 * `acf_get_field_type( $field['type'] )`
 * Will dive a bit deeper and report back.
 *  Thread Starter [Alex@portalZINE](https://wordpress.org/support/users/portalzine/)
 * (@portalzine)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/rest-api-error-36/#post-16462276)
 * Ok found the problem! As mentioned above the fieldtype needs to be registered
   within `acf-font-awesome-v5.php` or `acf-font-awesome-v6.php`
 * `$fa = new acf_field_font_awesome( $this->settings );
   acf_register_field_type(
   $fa );
 * Cheers
 *  Plugin Author [Matt Keys](https://wordpress.org/support/users/mattkeys/)
 * (@mattkeys)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/rest-api-error-36/#post-16462318)
 * Nice, that definitely points things in the right direction. A search for that
   function turns up this page:
 * [https://www.advancedcustomfields.com/resources/integrating-custom-field-types/](https://www.advancedcustomfields.com/resources/integrating-custom-field-types/)
 * This bit here seems to be referring to plugins like mine:
 * > For field types that are not registered with `acf_register_field_type()`, such
   > as field types that just construct themselves inside the `acf/include_field_types`
   > action hook, it is possible to include them in the REST API by using the `acf/
   > rest/get_fields` filter as shown below:
 * This plugin using the include_field_types action they reference.
 * Using the filter they suggest on that page will allow you to include FontAwesome
   into your REST fields without making any modifications to this plugin that would
   get overwritten during the next plugin update.
 * I’ll look into what the appropriate way would be for me to include this out of
   the box in a future update but that should get you what you need for now.
    -  This reply was modified 3 years, 4 months ago by [Matt Keys](https://wordpress.org/support/users/mattkeys/).
 *  Thread Starter [Alex@portalZINE](https://wordpress.org/support/users/portalzine/)
 * (@portalzine)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/rest-api-error-36/#post-16462323)
 * With the above changes I mentioned, all is working as it should now and no more
   exceptions 🙂
   Thanks
 *  Plugin Author [Matt Keys](https://wordpress.org/support/users/mattkeys/)
 * (@mattkeys)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/rest-api-error-36/#post-16462326)
 * Good to hear, I only mention the filter as it sounds like you made changes within`
   acf-font-awesome-v5.php` or `acf-font-awesome-v6.php`, and those changes will
   get lost on the next plugin update. If I read that wrong and you did your changes
   outside of this plugins codebase, then all is well.
 *  Thread Starter [Alex@portalZINE](https://wordpress.org/support/users/portalzine/)
 * (@portalzine)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/rest-api-error-36/#post-16462332)
 * I tried the hooks above before :), but none of them prevents the exception early
   enough. So for now I did tweak the plugin files to make it work 😉
 *  Plugin Author [Matt Keys](https://wordpress.org/support/users/mattkeys/)
 * (@mattkeys)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/rest-api-error-36/#post-16462337)
 * scandalous! 😲
 *  Thread Starter [Alex@portalZINE](https://wordpress.org/support/users/portalzine/)
 * (@portalzine)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/rest-api-error-36/#post-16462344)
 * I KNOW!! I am really sorry, but I added a big yellow sticky note to my monitor
   to remember 🙂

Viewing 10 replies - 1 through 10 (of 10 total)

The topic ‘REST API Error’ is closed to new replies.

 * ![](https://ps.w.org/advanced-custom-fields-font-awesome/assets/icon-256x256.
   jpg?rev=3435775)
 * [Advanced Custom Fields: Font Awesome Field](https://wordpress.org/plugins/advanced-custom-fields-font-awesome/)
 * [Support Threads](https://wordpress.org/support/plugin/advanced-custom-fields-font-awesome/)
 * [Active Topics](https://wordpress.org/support/plugin/advanced-custom-fields-font-awesome/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/advanced-custom-fields-font-awesome/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/advanced-custom-fields-font-awesome/reviews/)

 * 10 replies
 * 2 participants
 * Last reply from: [Alex@portalZINE](https://wordpress.org/support/users/portalzine/)
 * Last activity: [3 years, 4 months ago](https://wordpress.org/support/topic/rest-api-error-36/#post-16462344)
 * Status: resolved