You need to sign in to do that
Don't have an account?
Aryan 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;
}
}
}
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;
}
}
}
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
Let me know if this helps
Thanks,
Anudeep