mailerlite API error code 422 for subscribers endpoint

Donnerstag, 19. Mai 2022, 15:48 Uhr

Today, I was implementing the interfacing between and the Mailerlite API (which we use aus our newsletter software).

I got the following error message:

{"error":{"code":422,"message":"Unprocessable entity"}}

The POST request was returning 422 as status code.

Unfortunately there is little documentation about that on Mailerlite. My implementation was correct (this is Crystal Lang by the way):

get "/test" do |env| body = "{\"email\": \"\"}" puts body response ="", headers: HTTP::Headers{ "X-MailerLite-ApiKey" => "MAILERLITE_APIKEY", "Content-Type": "application/json" }, body: body) if response.status_code != 201 puts "newsletter_subscription :: error code #{response.status_code}" puts response.body else puts "newsletter_subscription :: OK" puts response.body end end

where MAILERLITE_APIKEY is the API key which you create in the backend:

(Click on “Generate new token”, it is displayed only once to you).

How to fix 422 when calling the subscribers endpoint of the Mailerlite API

The mailerlite support gave me the solution:

certain email addresses are rejected – e.g. email addresses which are support@<domain>. This is due to the bounce rate being higher on them.

How does a successful response look like?

With a different e-mail address, the response looks like this:

{“id”:2348923942342834,”name”:””,”email”:””,”sent”:0,”opened”:0,”opened_rate”:0,”clicked”:0,”clicked_rate”:0,”type”:”unconfirmed”,”country_id”:””,”signup_ip”:null,”signup_timestamp”:null,”confirmation_ip”:null,”confirmation_timestamp”:null,”fields”:[{“key”:”last_name”,”value”:””,”type”:”TEXT”},{“key”:”company”,”value”:””,”type”:”TEXT”},{“key”:”country”,”value”:””,”type”:”TEXT”},{“key”:”city”,”value”:””,”type”:”TEXT”},{“key”:”phone”,”value”:””,”type”:”TEXT”},{“key”:”state”,”value”:””,”type”:”TEXT”},{“key”:”z_i_p”,”value”:””,”type”:”TEXT”}],”date_subscribe”:”2022-05-19 12:09:24″,”date_unsubscribe”:null,”date_created”:”2022-05-19 12:09:24″,”date_updated”:”2022-05-19 12:09:24″}

The response code is 201, “created”.

Hire us

If you need support for your backend or frontend development, you can hire us. Get in touch for more information.

Der Beitrag mailerlite API error code 422 for subscribers endpoint erschien zuerst auf

pi3g e.K.

Als approved Raspberry Pi Reseller in Deutschland arbeiten wir seit Anfang an (2012) besonders eng mit Raspberry Pi zusammen. Wir bieten ehrliche, tiefe technische Kompetenz rund um den Raspberry Pi. Wir vertreiben Raspberry Pi sowie Coral AI hardware, und entwickeln Hardware und Software für unsere Kunden.

Unsere Plattform ermöglicht Nutzern ihre Pis von überall aus ganz leicht per Webinterface zu nutzen. Unsere Apps lösen echte Probleme und machen Nutzer glücklich.