Get job messages example


This sample shows how to retrieve all jobs messages kept in the JobMessage structure.
The particular job is referenced by its job id.
The JobMessage structure contains the text and/or a picture stored on a URL reference along with a timestamp of the message sent.
It is assumed that a valid api key is provided into the function.


        int jid = 313024;
        List<JobMessage> messages = GetJobMessages(apikey, jid);

        public class JobMessageList
            public List<JobMessage> Messages { get; set; }

        public class JobMessage
            public string Message { get; set; }
            public string UserId { get; set; }
            public string CreatedDate { get; set; }
            public string AttachmentUrl { get; set; }

        protected List<JobMessage> GetJobMessages(string apikey, int jid)
            var cli = new RestClient("");
            var request = new RestRequest("messages", Method.GET);
            request.AddQueryParameter("id", jid.ToString());
            request.AddQueryParameter("includeDeleted", "false");
            request.AddHeader("X-api_key", apikey);
            request.RequestFormat = DataFormat.Json;
            List<JobMessage> messages = new List<JobMessage>();
                var response = (RestResponse)cli.Execute(request);
                var jsonConverter = new RestSharp.Deserializers.JsonDeserializer();
                var list = jsonConverter.Deserialize<JobMessageList>(response);
                if (list != null)
                    messages = list.Messages;
            catch (Exception e)

            return messages;

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request