Using the create clip API

I’m having an issue with the create clip API. I’m getting the following error after making the call.

Array ( [error] => Bad Request [status] => 400 [message] => Missing required parameter "id" )

The user is authenticated properly, and here is the code that is calling the endpoint for creating the clip:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.twitch.tv/helix/clips");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Authorization: Bearer ' . $accessToken->getToken()
));
$output   = curl_exec($ch);
$response = json_decode($output, true);
curl_close($ch);

Any help would be greatly appreciated. Thank you!

You need pass the broadcaster_id parameter as part of the URL. I don’t see it being passed in your CURLOPT_URL line.

The documentation says the broadcaster_id parameter is optional.

I’ve tried with and without the broadcaster_id parameter and am receiving the same result.

That being said, I’m not really seeing how to determine the proper broadcaster_id, but even with an ID passed (I’m using my user ID) it’s still returning the same error.

Okay - I’ve found the initial issue in regards to the error. The endpoint for clips accepts both POST and GET. I was accidentally using GET and needed to add the post.

curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); 

This has resolved the issue. That being said, I’m still trying to figure out how to get the broadcaster_id for channels.

https://api.twitch.tv/helix/users?login=BarryCarlyon

A broadcaster id is the same as a user id

Docs Reference | Twitch Developers

Hmm if it’s optional, it would seem it would use the user_id of the authenticating user as the target channel to clip. Not tested…

I’ve tested without specifying the broascatser_id while providing a valid Bearer token and an error was still returned for the missing parameter.

I’ve posted about this in the Docs Feedback channel on the Twitch app, but no action has been taken yet.

2 Likes

Yes, I also noticed that it will not let you make the call without a broadcaster_id. Not a big deal, but the documentation had me a bit confused. Thanks for the help, everyone!

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