Skip to content

Instantly share code, notes, and snippets.

@bengolder
Last active June 21, 2016 15:44
Show Gist options
  • Save bengolder/1d27a6fe23156f7dd2c3eb6207f69d62 to your computer and use it in GitHub Desktop.
Save bengolder/1d27a6fe23156f7dd2c3eb6207f69d62 to your computer and use it in GitHub Desktop.
When I try to send a multiline email message through the Front API, all of the newline characters disappear, and I get a result similar to `bad_result.txt`
These should be separate lines of text.
import requests
import json
message = '''These
should be separate lines
of text.'''
data = {
'subject': 'Hello',
'body': message,
'text': message,
'to': to,
'options': {
'archive': False
}
}
payload = json.dumps(data)
requests.post(
url='https://api2.frontapp.com/channels/{}/messages'.format(settings.FRONT_EMAIL_CHANNEL_ID),
data=payload,
headers={
'Authorization': 'Bearer {}'.format(settings.FRONT_API_TOKEN),
'Accept': 'application/json',
'Content-Type': 'application/json'
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment