function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Aryan JhaAryan Jha 

How can we get channel id by passing parametre channel name by using integration Rest

public class YoutubeApi {
    public static String youtubechannelid(String channelname)
    {
        Http http =new Http();
        HttpRequest res=new HttpRequest();
        res.setEndpoint('https://www.googleapis.com/youtube/v3');
        res.setMethod('GET');
        HttpResponse resp=http.send(res);
        if(resp.getStatusCode()==200)
        {
            Map<String,Object>jsonbody=(Map<String,Object>)JSON.deserializeUntyped(res.getBody());
            List<object>result=(List<Object>)jsonbody.get('ChannelId');
            system.debug( result);
            return result;
        }
        
    }

}
AnudeepAnudeep (Salesforce Developers) 
Hi Aryan - I recommend JSON Parsing

Here is how the JSON response from a call to youtube looks like so we need to extract the channelId by parsing the response.  I suggest looking at the example gives in the documentation to extract parameters from JSON
 
{
  "kind": "youtube#searchListResponse",
  "etag": "\"xwzn9fn_LczrfK9QS3iZcGzqRGs/2ptDzqXXFWnBe5A1b1ypvIdH8NM\"",
  "nextPageToken": "CAUQAA",
  "regionCode": "US",
  "pageInfo": {
    "totalResults": 1000000,
    "resultsPerPage": 5
  },
  "items": [
    {
      "kind": "youtube#searchResult",
      "etag": "\"xwzn9fn_LczrfK9QS3iZcGzqRGs/XAQjwNlxoLq_epHnE2XFJB2G2sk\"",
      "id": {
        "kind": "youtube#video",
        "videoId": "AHX6tHdQGiQ"
      },
      "snippet": {
        "publishedAt": "2018-03-15T15:27:07.000Z",
        "channelId": "UCbxQcz9k0NRRuy0ukgQTDQQ",
        "title": "Ink Cartridges Are A Scam",
        "description": "Printer companies are ripping us off, and it's high time we did something about it. Join me in starting the revolution.",
        "thumbnails": {
          "default": {
            "url": "https://i.ytimg.com/vi/AHX6tHdQGiQ/default.jpg",
            "width": 120,
            "height": 90
          },
          "medium": {
            "url": "https://i.ytimg.com/vi/AHX6tHdQGiQ/mqdefault.jpg",
            "width": 320,
            "height": 180
          },
          "high": {
            "url":

 Let me know if this helps

Thanks, 
Anudeep
Aryan JhaAryan Jha
There is any problem in this program is there may mistake