ActiveCampaign / postmark-wordpress

The Official Postmark Wordpress Plugin
GNU General Public License v2.0
18 stars 17 forks source link

ErrorCode 403 : Invalid request field(s): $.Metadata #113

Open tflight opened 4 months ago

tflight commented 4 months ago

Hi,

I've been getting this error when sending some emails. The emails which it fails on seem fairly random, though it occurs more commonly with some types of emails than others.

{"ErrorCode":403,"Message":"Invalid request field(s): $.Metadata"}

I've read this article on Changes to Email API validation and it seems related. I am using the postmark_metadata filter in my emails. So I'm unsure if I'm doing something incorrect or if the plugin should be updated to do additional validation before sending along the email.

https://github.com/ActiveCampaign/postmark-wordpress/blob/aa523b78a66f774275be1c7d92e80991ffa1136c/wp-mail.php#L234-L237

I'm using the filter like this:

add_filter('postmark_metadata', 'cc_postmark_metadata');
function cc_postmark_metadata($metadata)
{
    if (isset($_SERVER['REMOTE_ADDR'])) {
        $metadata['remote_ip'] = $_SERVER['REMOTE_ADDR'];
    }

    return $metadata;
}

I've turned off this filter for now to make sure this is where the issue is coming from.