How do I grab the thread in a custom function?

How do I grab the thread in a custom function?

I need the sample code for grabbing thread content from an email and put it in ticket description.

Do I need to make an API call for this? 

When I tried making an API call for the thread content, I got an error for: 
{"errorCode":"UNAUTHORIZED","message":"You are not authenticated to perform this operation."}

What am I missing from this code?
con = invokeurl
[
url: "https://desk.zoho.com/api/v1/tickets/"+ticketId+"/conversations"
type: GET
];
            Zoho Marketing Automation

                      Zoho Pagesense Resources

                        Zoho SalesIQ Resources



                              Zoho TeamInbox Resources

                                Zoho DataPrep Resources



                                  Zoho CRM Plus Resources

                                    Zoho Books Resources


                                      Zoho Subscriptions Resources

                                        Zoho Desk Resources

                                          Zoho Projects Resources


                                            Zoho Sprints Resources


                                              Qntrl Resources


                                                Zoho Creator Resources


                                                  Zoho WorkDrive Resources



                                                    Zoho Campaigns Resources

                                                      Zoho CRM Resources

                                                            Design. Discuss. Deliver.

                                                            Create visually engaging stories with Zoho Show.

                                                            Get Started Now