Cant PUT stream STATUS via JS/AJAX (selfSolved)

Good day. Im trying to change my channel title by using this code:

jsontext = JSON.stringify(['channel', {'status': 'MY TITLE'}]);
    $.ajax({
        url: 'https://api.twitch.tv/kraken/channels/mychannel',
        type: 'PUT',
        headers: {
            Accept: "application/vnd.twitchtv.v2+json",
            Authorization: "OAuth "+token
        },
        dataType: "json",
        contentType: "application/json",
        data: jsontext,
        success: function(data) {
          console.log(data.status);
        }
   });

but nothing changes and here what console tells me:

No 'Access-Control-Allow-Origin' header is present on the requested resource.

However when i use Chrome app named POSTMAN to test my url it works perfectly.

Did I forget something in my code?

Thanks to developers for undocumented feature ‘&_method=put’ ):

$.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 now.

1 Like