mailjet / mailjet-gem

[API v3] Mailjet official Ruby GEM
https://dev.mailjet.com
Other
130 stars 72 forks source link

Dedicated propery for X-MJ-EventPayload through Maijet::Send.create ? v 3.1 #182

Closed omarsotillo closed 5 years ago

omarsotillo commented 5 years ago

Hey! currently I am using the header X-MJ-EventPayload but apparently is forbidden. Need to use this one to be sent on the real-time events approach that is currently working in another application with the ActionMailer approach. It tells me to use the dedicated property but don´t find it in the documentation for this approach but only for ActionMailer

    def headers
      {
        'X-KP-ARCHIVE' => 'true',
        'X-MJ-EventPayload' => mailjet_event_payload.to_json
      }
    end

    def mailjet_event_payload
      {
        'type' => 'mailjet_status',
        'application' => 'customer_api',
        'email_type' => 'CustomerApi::PremiumContentRequest',
        'relations' => [{ 'name' => 'premium_content_request',
                          'id' => @recipient.email }]
      }
    end

Error given is the following on the resque (Header needs to use the dedicated property):

"{\"Messages\":[{\"Status\":\"error\",\"Errors\":[{\"ErrorIdentifier\":\"8505b66f-c9e9-4c9a-8018-e741ae7c4e2c\",\"ErrorCode\":\"send-0011\",\"StatusCode\":400,\"ErrorMessage\":\"Header cannot be customized using the \\\"Headers\\\" collection. Please use the dedicated property to set this header.\",\"ErrorRelatedTo\":[\"Headers[\\\"X-MJ-EventPayload\\\"]\"]}]}]}" Please see https://dev.mailjet.com/guides/#status-codes for more informations on error numbers.