Webhooks arent reporting application/json in its Content-Type header

I am trying to set up a simple app that listens for Plex’s webhook using Flask/python. When certain players are started, it will dim the lights on my Haiku fans (using another custom driver). My code for flask is

from flask import Flask, request, jsonify
app = Flask(__name__)

@app.route('/api/add_message/<uuid>', methods=['GET', 'POST'])
def add_message(uuid):

    #app.logger.debug("JSON received...")
    #app.logger.debug(request.json)

    content = request.get_json()
    print content
    return jsonify({"uuid":uuid})

if __name__ == '__main__':
    app.run(host= '0.0.0.0', port=8088, debug=True)

When Plex posts to my URL, it throws out the JSON because the header isn’t correct. If I manually curl a fake JSON to my url, my little app detects it just fine and prints it back.

Is this something Plex needs to fix or do I have to somehow get around it?

@dcplaya ~ remember the POST is a multipart body; the part which has JSON should be the correct type.

@elan said:
@dcplaya ~ remember the POST is a multipart body; the part which has JSON should be the correct type.

I skipped over this in the documentation! This is definitely helpful and I can finally get the data to print to my screen. Now I just have to figure out how to separate all the values (which isn’t a Plex issue, just me learning). Thanks elan!

You’re a lucky guy to have Haiku fans, I’ve always drooled over those!

@elan said:
You’re a lucky guy to have Haiku fans, I’ve always drooled over those!

I just pick up another. Little secret… call them and ask for refurbs. Got it for about half price! Still pricey but better than full price. And their premium lights are awesome too! (I don’t work for them but they are a great company I think) My attempt to make my own API (I forked part of this from another guy) is github.com/dcplaya/SenseMe/tree/v0.2

Wow, thanks for the idea!