Thanks for taking the time to read this. I'm confused on how to insert a comment using the YouTube API. I'm fairly new to using APIs, so I don't quite get what they are saying to do in their documentation.
I've authenticated the user using Google Sign-In for iOS with the scope
"https://www.googleapis.com/auth/youtube.force-ssl"
which is required to insert a comment. But now, I have to actually insert the comment and (like I've said) I don't understand how to do that because I have to provide a resource in the request body. I'm using Alamofire for the request and Swift 4 as my language. I would highly appreciate it if someone could help me.
As I saw in your other post (Google API - Invalid Credentials) you know how to make an authenticated
Alamofire
request. Now you need to build a proper parameters dictionary to meet the API requirements. I looked into the Youtube Data API guide.This is the example of a JSON body provided in the documentation for adding a comment:
Let's build a parameters dictionary based on the above example, it is a nested dictionary:
Then create your headers, your request and pass the parameters to the request
You should check which parameters are mandatory and which ones are not, but the idea is to build a proper parameters dictionary based on their requirements.