Appendix

Sample c# code

OVERVIEW

 

using System;

using System.Collections.Generic;

using System.IO;

using System.Linq;

using System.Net;

using System.Text;

using System.Threading.Tasks;

using System.Xml;

using System.Xml.Linq;

namespace CollaborateRestClient

{

    class Program

    {

        static void Main(string[] args)

        {

            string uri = "https://collaboratev3.highqsolutions.com/collaboratev3/api/1/files/686";

            try

            {

                var webRequest = (HttpWebRequest)WebRequest.Create(uri);

                //this is the default method/verb, but it's here for clarity

                webRequest.Method = "GET";

                webRequest.Accept = "application/xml";

                webRequest.Headers.Add("Authorization", "Bearer  yourauthcodegoeshere ");

                webRequest.Headers.Add("Auth-Type", "OAUTH2");

                var webResponse = (HttpWebResponse)webRequest.GetResponse();

                String responseString;

                using (Stream stream = webResponse.GetResponseStream())

                {

                   StreamReader reader = new StreamReader(stream, Encoding.UTF8);

                   responseString = reader.ReadToEnd();

                }

                Console.WriteLine(responseString);

            }

            catch (WebException ex)

            {

                Console.WriteLine("Error occured:" +  ex.ToString());

            }       

        }

    }

}

Comments


7 Comments

Last Updated: Nov 08,2024