Zapier Python Code Error Segment.com (usercode.py, line 9)
<p>I'm trying to take Campaign Monitor Open events and pipe the data to Segment.com via POST API using Python code Action on Zapier.</p>

<p>I keep getting the following <strong>error</strong>:</p>

<blockquote>
  <p>Bargle. We hit an error creating a run python. :-( Error: 
  Your code had an error! Traceback (most recent call last): SyntaxError: invalid >syntax (usercode.py, line 9)</p>
</blockquote>

<p>Here is the existing setup screenshot (masking the auth code):
<a href="http://i.stack.imgur.com/ee3Z2.png" rel="nofollow">Zapier Zap Setup for Code</a></p>

<p>The Python code returning the error is:</p>

<pre><code>url = 'https://api.segment.io/v1/track/'
payload =
{
  'userId': input_data['email'],
  'event': 'Email Opened',
  'properties': {
    'listid': input_data['listid'],
    'open_date': input_data['date'],
    'cm_id': input_data['cm_id'],
    'open_city': input_data['city'],
    'open_region': input_data['region'],
    'open_country': input_data['country'],
    'open_lat': input_data['lat'],
    'open_long': input_data['long'],
    'open_country_code': input_data['country_code']
  },
  'context': {
    'ip': input_data['ip']
  }
}

headers = {
    'content-type': 'application/json',
    'Authorization': 'Basic BASE64ENCODEDWRITEKEY'
}

response = requests.post(url, data=json.dumps(payload), headers=headers)
response.raise_for_status()
return response.json()
</code></pre>

<p>Any advice on what the error may be referencing? Any advice overall on how to better achieve this?</p>

<p>Thanks to @Bryan Helmig. That syntax, in addition to import json fixed the issue. For those interested, this works...</p>

<pre><code>import json
import requests
url = 'https://api.segment.io/v1/track/'
payload = {
  'userId': input_data['email'],
  'event': 'Email Opened',
  'properties': {
    'listid': input_data['listid'],
    'open_date': input_data['date'],
    'cm_id': input_data['cm_id'],
    'open_city': input_data['city'],
    'open_region': input_data['region'],
    'open_country': input_data['country'],
    'open_lat': input_data['lat'],
    'open_long': input_data['long'],
    'open_country_code': input_data['country_code']
  },
  'context': {
    'ip': input_data['ip']
  }
       }

headers = {
    'content-type': 'application/json',
    'Authorization': 'Basic WRITEKEYHERE'
}

response = requests.post(url, data=json.dumps(payload), headers=headers)
response.raise_for_status()
</code></pre>

python zapier segment-io