Search code examples
jqueryajaxapiputtwitch

Twitch Api - Changing channel status fail via jQuery Ajax put method


Good day. Im trying to change stream title via this code:

titleStr = "Playing cool new game!";

$.ajax({
            url: 'https://api.twitch.tv/kraken/channels/my_channel?channel[status]='+titleStr+'&oauth_token=' +token,
            type: 'PUT',
            dataType : 'jsonp',
            contentType: 'application/json',
            success: function(data) {
              console.log(data.status);
            }
});

It returns succsess (current title), but nothing changes. However i tested url with Chrome App named Postman and its perfectly works.

UPD: Twitch API


Solution

  • Finally solved. Twitch api have an undoc feature '&_method=put' thru 'GET' =\

    $.ajax({
                url: 'https://api.twitch.tv/kraken/channels/mychannel?channel[status]='+titleStr+'&oauth_token=' +token+'&_method=put',
                type: 'GET',
                contentType: 'application/json',
                dataType: 'jsonp',
                success: function(data) {
                  console.log(data.status);
                }
    }); 
    

    This code works well.