1

I'm using YouTube Reporting Api to get my CMS account's datas as bulk reports.

I am using Api Explorer with my CMS user account. I have enabled YouTube Reporting API from console but whenever I'm trying the following request, I get 401 error. I believe that I'm missing something or doing something wrong but I couldn't find it. What is the exact reason of this issue?

Mr. Ibrahim Ulukaya , you are the one who created the PHP sample codes for YouTube Reporting API. How can I solve this issue?

Thank you! :)

This is my request;

POST https://youtubereporting.googleapis.com/v1/jobs?onBehalfOfContentOwner=contentOwner%3D%3DContent_Owner_Name&fields=id%2CreportTypeId&key={YOUR_API_KEY}

{ "reportTypeId": "content_owner_ad_performance_a1" }

This is the Response;

401 OK

  • Show headers -

{ "error": { "code": 401, "message": "The request does not have valid authentication credentials.", "status": "UNAUTHENTICATED" } }

Edit

When I don't add Content Owner name, I get 400 Error..

Here's my request;

POST https://youtubereporting.googleapis.com/v1/jobs?fields=name%2CreportTypeId&key={YOUR_API_KEY} { }

Here's the response;

400 OK

  • Show headers -

{ "error": { "code": 400, "message": "Request contains an invalid argument.", "status": "INVALID_ARGUMENT" } }

iwocan
  • 266
  • 3
  • 13

1 Answers1

0

I solved this problem...

401 error happens because I was thinking that I should add my Content Owner Name at OnBehalfOfContentOwner section. According to YouTube documentation, It's supposed to be my Content Owner ID. (The content owner's external ID on which behalf the user is acting on.) When I added my Content Owner ID, the request was fine..

400 Error happens because I left the OnBehalfOfContentOwner section blank and didn't write anything. According to YouTube documentation, f the request does not specify a value for this parameter, the API server assumes that the request is being made for the user's own channel.. If it is acting as your own channel (not content owner), you cannot retrieve anything from Content Owner Reports. You can only choose something from Channel Reports. If you try retrieving data from Content Owner Reports while acting as your own channel, the request will be invalid because it cannot see the report in the Channel Report list.

The most important things are;

  • If you are trying to retrive Content Owner reports, you should use your Content Owner ID , not Content Owner name on OnBehalfOfContentOwner section.

  • You should choose a correct report id from the list which you are acting as...

iwocan
  • 266
  • 3
  • 13