Discussions

Ask a Question
Back to All

What am I doing wrong with posting to the Feed?

Hey ServiceM8 DevRel team,

I'm trying to figure out how to post to the feed using the feed API in Python and it is not working. This is the code I am using:

url = "https://api.servicem8.com/platform_feed_post"

payload = {
"type": "Note",
"message": "This is a test. @travis",
"showActionBar": 1
}
headers = {
"accept": "/",
"content-type": "application/json",
"authorization": sm8_funcs.get_json_data("header_auth")
}

response = requests.post(url, json=payload, headers=headers)

The server returns this header info:

{
"Content-Type":"text/html; charset=UTF-8",
"Content-Length":"0",
"Connection":"keep-alive",
"Date":"Fri, 06 Dec 2024 00:57:23 GMT",
"Server":"Apache",
"Strict-Transport-Security":"max-age=63072000; includeSubDomains",
"X-Frame-Options":"SAMEORIGIN",
"X-Cache":"Error from cloudfront",
"Via":"1.1 94cda5dabbd4d7c2c2ed13771099b7f6.cloudfront.net (CloudFront)",
"X-Amz-Cf-Pop":"DFW57-P5",
"Alt-Svc":"h3=":443"; ma=86400",
"X-Amz-Cf-Id":"W-9GCNSy3G7ogpDxV9-73_DEM-F1tLgoCdWJ5IFJImEk9jR0J3T6Tg=="
}

Needless to say it is not working. What am I doing wrong?

Thanks!

-Travis