What am I doing wrong with making a call to the Replace Stream Tags endpoint? Node.js

Everything goes through as expected, and I don’t seem to be running into issues with the request going through. Just that I’m getting a 400 error when doing so.

I have the request itself look like this:

			const s = await this.#data_base.getIdAndSecret();
			const data = {
				'method': 'PUT',
				'headers': {
					'client-id': `${s[0]}`,
					'Authorization': `Bearer ${await this.#data_base.getTwitchInfo(0)}`,
					'Content-Type': 'application/json'
				},
				'body': {
					'tag_ids': tags_array
				}
			};

where the data_base object is my secured SQLite database and the tags array is the list of tags I want to apply to the stream. To send out the request, I’m using the node-fetch library.

I’m making the call to this specific URL:

https://api.twitch.tv/helix/streams/tags?broadcaster_id=**********

where the stars represent my own broadcaster id.

I’m not certain why I’m getting this issue, as I didn’t think I was doing anything wrong. The bot is an editor to my channel, and all other API requests go through as normal. Just that this one doesn’t for some reason.

Any help would be appreciated, and I apologize if this is something that was already asked and answered.

Whats the message in the body?

The HTTP Code is half the information needed to stolve this. The body should have a JSON body that contains a message which describes the issue.

You declared JSON as the Content-Type but your bdoy is not JSON. It’s an Object.

You may need to JSON.stringify

So

				'body': {
					'tag_ids': tags_array
				}

becomes

				'body': JSON.stringify({
					'tag_ids': tags_array
				})

This is irrelevant since the API uses YOUR token, not the bot’s token.

1 Like

christ on a crutch, I KNEW I was doing something dumb. Yeah, your fixed worked perfectly

Thank you so much for the help!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.