Modifying Twitch stream video metadata using API: thumbnail and description issues

I’m having trouble updating Twitch stream info. The code works for tags and title, but not for description and thumbnail. Here’s what I’m seeing:

2024-06-26 10:55:38,843 - INFO - Twitch token is valid
2024-06-26 10:55:39,578 - INFO - Updated stream info - Title: SORA Video To Video Is Literally Mind Blowing - 12 HD Demos - Changes Industry Forever For Real, Category: Science & Technology, Tags: ['technology', 'learning', 'software', 'education', 'howto', 'tech', 'programming', 'development', 'science', 'lecture']
2024-06-26 10:55:39,703 - ERROR - Failed to update stream info: 400 Client Error: Bad Request for url: https://api.twitch.tv/helix/channels?broadcaster_id=906233081

I’m using this method to update the stream info:

async def change_stream_details(self, headline, summary, preview_image):
    headers = {
        'Client-ID': self.app_id,
        'Authorization': f'Bearer {self.auth_token["access_token"]}',
    }
    
    headline = headline[:140]
    keywords = get_keywords(headline, summary)
    
    tech_category_id = '509670'
    
    payload = {
        'broadcaster_id': self.streamer_id,
        'title': headline,
        'game_id': tech_category_id,
        'broadcaster_language': 'en',
        'tags': keywords
    }
    
    try:
        result = requests.patch(f'https://api.twitch.tv/helix/channels?broadcaster_id={self.streamer_id}', 
                                headers=headers, 
                                json=payload)
        result.raise_for_status()
        print(f"Stream details updated - Headline: {headline}, Category: Science & Technology, Keywords: {keywords}")

        if preview_image:
            image_data = {'thumbnail_url': preview_image}
            image_result = requests.patch(f'https://api.twitch.tv/helix/channels?broadcaster_id={self.streamer_id}',
                                          headers=headers,
                                          json=image_data)
            image_result.raise_for_status()
            print(f"Stream preview image updated: {preview_image}")

    except requests.RequestException as e:
        print(f"Error updating stream details: {e}")
        print(f"Response: {e.response.content if e.response else 'No response'}")

I also tried updating the description after the stream ends, but it’s not working. Any ideas on how to fix this?

hey bro, looks like ur havin some api troubles. twitch can be a pain sometimes. for the thumbnail, make sure ur using a valid image URL. description might not be updateable thru that endpoint. maybe try the ‘channel information’ endpoint instead? also double-check ur auth token has the right scopes. good luck man!