Skip to content

Commit

Permalink
Make customer.io happy with the Content-Type (#5)
Browse files Browse the repository at this point in the history
Fixes:

```
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/async_customerio/client_base.py", line 79, in send_request
    raise AsyncCustomerIOError(f"{result_status}: {url} {json_payload} {raw_cio_response.text}")
async_customerio.errors.AsyncCustomerIOError: 400: https://api-eu.customer.io/v1/send/email {...} {
  "meta": {
    "error": "Non-JSON content type application/json; UTF-8 in request header."
  }
}

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/asyncio/tasks.py", line 445, in wait_for
    return fut.result()
  File "/app/worker/jobs.py", line 18, in send_email
    return await customerio.send_email(request)
  File "/usr/local/lib/python3.10/site-packages/async_customerio/api.py", line 136, in send_email
    return await self.send_request(
  File "/usr/local/lib/python3.10/site-packages/async_customerio/client_base.py", line 83, in send_request
    raise AsyncCustomerIOError(
async_customerio.errors.AsyncCustomerIOError: Failed to receive valid response after 3 retries.
Check system status at http://status.customer.io.
Last caught exception -- <class 'async_customerio.errors.AsyncCustomerIOError'>: 400: https://api-eu.customer.io/v1/send/email {...} {
  "meta": {
    "error": "Non-JSON content type application/json; UTF-8 in request header."
  }
}
```
  • Loading branch information
ramnes authored Jan 3, 2023
1 parent 0b22a69 commit b5b2b81
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 0.4.1

- The ``Content-Type`` we use has been updated so that Customer.io is happy when we try to send emails.

## 0.4.0

- Class ``AsyncCustomerIO`` updated with docstrings.
Expand Down
2 changes: 1 addition & 1 deletion async_customerio/client_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def _prepare_headers(self):
"""Prepare HTTP headers that will be used to request CustomerIO."""
logging.debug("Preparing HTTP headers for all the subsequent requests")
return {
"Content-Type": "application/json; UTF-8",
"Content-Type": "application/json",
"X-Request-Id": self._get_request_id(),
"User-Agent": "async-customerio/{0}".format(pkg_resources.get_distribution("async-customerio").version),
}
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "async-customerio"
version = "0.4.0"
version = "0.4.1"
description = "Async CustomerIO Client - a Python client to interact with CustomerIO in an async fashion."
license = "MIT"
authors = [
Expand Down

0 comments on commit b5b2b81

Please sign in to comment.