Setting the stream status/game/delay in perl via JSON

Trying to post JSON encoded data to set stream title/game/delay etc, however it seems to be setting everything correct as per the data dumper output, but i’m getting a 401 back, any ideas? i’m kinda stumped. The oauth key is correct - in fact i tried regenerating it and still get the same thing “Token Invalid or missing required scope”. I saw a couple of other posts that say i should put “?oauth_token=” in the URL, but it thought that was just for a URLEncoded string as shown in the docs.

any help appreciated

my $channelname = “channelname”;
my $OAUTH_KEY = “obvious”;

my @channeljson = ( { “status” => $status,
“game” => $stream_game,
“delay” => $stream_delay

            my $j = JSON::XS->new->encode({channel => \@channeljson});

            #set the headers, 
            my $headers = {
                    Content_Type => 'application/json',
                    Accept => 'application/vnd.twitchtv.v2+json',
                    Authorization => 'OAuth ' . $OAUTH_KEY

            my $client = REST::Client->new();


            #create the host
            $client->PUT("/kraken/channels/" . $channelname, ($j,$headers));

            print Dumper($headers);
            print Dumper($j);

            #decode the response in perl a type
            my $response = from_json ($client->responseContent());

            #print the response
            print Dumper($response);

Just as an aside, i even ran it manually using the oauth token I received from the auth section using curl as described in the api docs and i get the same error

curl -H ‘Accept: application/vnd.twitchtv.v3+json’ -H ‘Authorization: OAuth MYKEY’ -d “channel[status]=wtf&channel[game]=undefined&channel[delay]=0” -X PUT CHANNEL

and i get this in reply:

{“error”:“Unauthorized”,“status”:401,“message”:“Token invalid or missing required scope”}

now the scope that i requested for that was which is i beleive alli would actually need to set the status/game/delay etc:


ok so i’m getting a bit further.

I finally figured out it was a damn typo in the oauth key… but i’m now getting a “length required” error which as you can see is being put into the headers, ideas?

$headers = {
‘Accept’ => ‘application/vnd.twitchtv.v3+json’,
‘Content_Type’ => ‘application/json’,
‘Content_Length’ => 63,
‘Authorization’ => ‘OAuth mykey’

$jsondata = ‘{“channel”:[{“game”:null,“status”:“THIS+IS+A+TEST”,“delay”:0}]}’;

$server_reply = {
‘error’ => ‘Internal Server Error’,
‘message’ => undef,
‘status’ => 500

(and in the console)

curl: (3) [globbing] bad range in column 13

411 Length Required

411 Length Required

nginx curl: (3) [globbing] bad range in column 13 % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 174 100 174 0 0 342 0 --:--:-- --:--:-- --:--:-- 343

After a quick google search, i think you have another typo. it’s “content-length” and not “content_length”

yea i noticed that after i posted it but it’s still doing the same thing, and according to the CURL docs when run from the command line, it automatically puts it in… like i said, i tried the example given in the docs and put my key in, still got the same thing,

i got it… perl was’t doing what i was expecting with the json object////