0

Clicking on either of the rating buttons on my SONOS app causes an "Operation failed" error to appear and I don't know why. Everything else about the app works as expected except for that.

Here is the code for my rate item function. I'm using the pysimplesoap module.

def rateItem(id, rating, device, householdId, loginToken):
    # rating =
    # Unrated track -> rating = 1 (good) | rating = 0 (bad)
    # Track has thumbs up  -> rating = 3 (good) | rating = 2 (bad)
    # Track has thumbs down -> rating = 5 (good) | rating = 6 (bad)
    user_record = SonosUserRecord.collection.find_one({"loginToken": loginToken})
    user = get_user_from_username(username=user_record["username"])

    now = datetime.utcnow()
    SonosUserRecord.collection.update({"loginToken": loginToken}, {"$set": {"last_update": now}})
    #rateItemResponse = {"shouldSkip": "false"}
    if rating == 1 or rating == 5:
        print "Rated positive"
        # Rated positive
        rating_value = 5
        toid = id.split(":")[1]
        rating = MongoTrackRating(user, toid)
        rating.set_rating(int(rating_value))
        MongoTrackRatingAggregate.update_track_rating_aggregate(toid, int(rating_value))
    if rating == 0 or rating == 2:
        print "Rated negative"
        # Rated negative
        #rateItemResponse["shouldSkip"] = "true"
        rating_value = 1
        toid = id.split(":")[1]
        rating = MongoTrackRating(user, toid)
        rating.set_rating(int(rating_value))
        MongoTrackRatingAggregate.update_track_rating_aggregate(toid, int(rating_value))
    return rateItemResponse

And then I register it.

dispatcher.register_function('rateItem', rateItem,
    returns={"rateItemResult": list},
    args={"id": str, "rating": int, 'device':str, 'householdId':str, 'loginToken': str})

What am I missing?

terratunaz
  • 614
  • 3
  • 9
  • 19
  • Please add the SOAP envelope you return in the `rateItemResponse` by capturing the response with Wireshark or something similar. From the code above, it is possible you're returning an empty envelope. – devonlazarus Oct 12 '16 at 03:58
  • 1
    Hey thanks for the suggestion to use Wireshark. I was able to figure out the cause. Apparently my update_track_rating_aggregate method wasn't taking in the right amount of params. Fixed that and the error went away! – terratunaz Oct 13 '16 at 14:56

0 Answers0