Title: Double json_encode for PATCH requests
Last modified: July 17, 2022

---

# Double json_encode for PATCH requests

 *  Resolved [noplanman](https://wordpress.org/support/users/noplanman/)
 * (@noplanman)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/double-json_encode-for-patch-requests/)
 * Hi,
 * I’m making use of the API connection in some custom code and have run into a 
   bug.
 * When making PATCH requests, the body is being double-encoded.
 * This first encoding happens when preparing the request [here](https://plugins.trac.wordpress.org/browser/aweber-web-form-widget/tags/7.3.2/php/aweber_api/oauth2_application.php#L303).
   
   The double happens just before dispatching it [here](https://plugins.trac.wordpress.org/browser/aweber-web-form-widget/tags/7.3.2/php/aweber_api/oauth2_application.php#L149).
 * (same thing for OAUTH1 [here](https://plugins.trac.wordpress.org/browser/aweber-web-form-widget/tags/7.3.2/php/aweber_api/oauth_application.php#L519)
   and [here](https://plugins.trac.wordpress.org/browser/aweber-web-form-widget/tags/7.3.2/php/aweber_api/oauth_application.php#L537))
 * Fix is to remove the secondary `json_encode` in the `patch()` and `http_patch()`
   methods.
 * My use-case: adding and removing tags, which requires multi-level arrays.
 * P.S. Is the source code in a public repository and open to PRs somewhere?

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

 *  [steveaweber](https://wordpress.org/support/users/steveaweber/)
 * (@steveaweber)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/double-json_encode-for-patch-requests/#post-15843919)
 * Hey,
 * I have talked to the developers of the integration and it looks like that is 
   line is something that was left in and is not used by the plugin at all.
 * The suggested work around would be using something like
    `$this->get_api_response(
   $url, wp_remote_request($url, $options));` I know this is not ideal. What you
   could do as well is make your own integration and then make your own patch request.
   I hope this help but please let me know if you have any further questions.
 *  Thread Starter [noplanman](https://wordpress.org/support/users/noplanman/)
 * (@noplanman)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/double-json_encode-for-patch-requests/#post-15844069)
 * Hi Steve,
 * Thanks for your reply.
 * To be quite frank, I can’t understand how an official plugin from AWeber doesn’t
   fix a bug in their code, even if it’s not used internally.
 * I’d expect the API provided by this plugin to be the truest reflection of the
   AWeber API, so that any developers who would like to create simple extensions,
   can use this plugin as a base. Forking for my own needs is always the last option
   for me, as a fix would benefit everyone!
 * If the code were open source I’d be more than happy to make a fix.
 * P.S. I’ve seen other plugins that use the AWeber API code that’s in this plugin,
   and they have the bug too…
 *  Thread Starter [noplanman](https://wordpress.org/support/users/noplanman/)
 * (@noplanman)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/double-json_encode-for-patch-requests/#post-15847532)
 * Hello again,
 * I’m flabbergasted with the latest update to the plugin, version 7.3.3.
 * Instead of fixing a single line of code, the decision has been made to remove
   parts of the API…
 * Very sad to see how actively AWeber doesn’t want to create a developer-friendly
   experience here.
 * Uninstalling now…
 *  Plugin Author [AWeber Communications, Inc.](https://wordpress.org/support/users/aweber/)
 * (@aweber)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/double-json_encode-for-patch-requests/#post-15847742)
 * Thank you for pointing out the unused function inside the plugin. As it was not
   being used by our plugin it was removed.
 * While I understand you were attempting to use a function inside the AWeber WordPress
   plugin to make another plugin, that is not a supported use of our plugin. Piggybacking
   off the existing AWeber oauth connection inside our plugin for your own plugin
   is a violation of user trust and a potential security vulnerability. If you are
   writing a WordPress plugin, please register your own developer profile and use
   the credentials issued for that specific plugin so end users have a clear delineation
   of who’s doing what with their data.
 * A developer profile can be created free at [https://labs.aweber.com/](https://labs.aweber.com/)
   
   Docs for API functions can be found at [https://api.aweber.com/](https://api.aweber.com/)
 * -Tom Kulzer
 *  Thread Starter [noplanman](https://wordpress.org/support/users/noplanman/)
 * (@noplanman)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/double-json_encode-for-patch-requests/#post-15851485)
 * Hi Tom,
 * Thank you for the clear response.
 * Since this plugin is developed by AWeber itself, I wrongly assumed it was the
   safest way to do this.
 * It is very clear now that I need to develop our own integration, which I’ll go
   ahead and do.
 * Armando

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

The topic ‘Double json_encode for PATCH requests’ is closed to new replies.

 * ![](https://ps.w.org/aweber-web-form-widget/assets/icon-256x256.png?rev=2496137)
 * [AWeber – Free Sign Up Form and Landing Page Builder Plugin for Lead Generation and Email Newsletter Growth](https://wordpress.org/plugins/aweber-web-form-widget/)
 * [Support Threads](https://wordpress.org/support/plugin/aweber-web-form-widget/)
 * [Active Topics](https://wordpress.org/support/plugin/aweber-web-form-widget/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/aweber-web-form-widget/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/aweber-web-form-widget/reviews/)

 * 6 replies
 * 3 participants
 * Last reply from: [noplanman](https://wordpress.org/support/users/noplanman/)
 * Last activity: [3 years, 10 months ago](https://wordpress.org/support/topic/double-json_encode-for-patch-requests/#post-15851485)
 * Status: resolved