Follow

Calendar(Activities) Search 'calendar/search' POST method

The purpose of this method is to retrieve a list of activities. The table below, on a request basis, will grow quite a bit larger than it currently is. As of right now, here's whats available.   

 

Search Fields
Enumerator
Field
Info
Operands Available
0
LastUpdate
Last Update
ALL
2
RecAdd
Date Added
ALL
3
AllDay
All Day Activity
ALL
4
StartDate
Start Date
ALL
5
EndDate
End Date
ALL
6
Type
Activity Type
ALL
7
Complete
Completion flag
ALL
8
Subject
Subject
ALL
9
Location
Location
ALL
10
Reminder
Reminder
ALL
20
ContactID
Assigned to Contact Identifier
ALL
21
UserID
Assigned to User Identifier
ALL

 

The operands are enumerated as well. Here's how they mapped out.

Operands
Enumerator
Operand
0
Equals
1
Greater Than 
2
Less Than
3
Not Equal To
4
Like
5
Begins With
6
Is Empty?

 

Examples:

So to illustrate, here are a few examples in JSON with their SQL equivalents. You will be using similar JSON(Or XML) in your Request Body.

 

To return all of the activities updated since 2013-08-05

JSON:

[{"Field":"0","Operand":"1","Value":"2013-08-05"}]

The SQL Equivalent:

SELECT * FROM Table1 WHERE LastUpdate > '2013-08-05'

 

To retrieve a client with a ContactID 384843'.

JSON:

[{"Field":"20","Operand":"0","Value":"384843"}]

The SQL Equivalent:

SELECT * FROM Table1 WHERE ContactID = '384843'

 

To be more restrictive, you can search against multiple criteria.

For example, if you would like to retrieve a list of activities for ContactID 384843 that have been lastupdated since 2013-08-05, you can search against both fields as follows.

JSON:

[{"Field":"0","Operand":"1","Value":"2013-08-05"},{"Field":"20","Operand":"0","Value":"384843"}]

The SQL Equivalent:

SELECT * FROM Table1 WHERE ContactID = 384843 and LastUpdate > '2013-08-05'

 

Below is the sample request based on our first example. Notice that I've added the query string ?page=1. This is unnecessary for the first page, but you will want to specify the page # for any page thereafter. The method is paged for every 50 records returned.

 

Request Header example (C#)

HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create("https://api2.redtailtechnology.com/crm/v1/rest/calendar/search?page=1");
req.Headers[System.Net.HttpRequestHeader.Authorization] = "Basic " + Convert.ToBase64String(System.Text.Encoding.Default.GetBytes("6C135EDF-C37C-4039-AEF3-5DFC079F9E6A:statementone:sonedemo"));
byte[] reqdata = System.Text.Encoding.ASCII.GetBytes(ActivitySearchPost);
req.Method = "POST";
req.ContentType = "text/json"; 
req.GetRequestStream().Write(reqdata, 0, reqdata.Length);


Request Body example (C#)

string reqJSON = "[{\"Field\":\"0\",\"Operand\":\"1\",\"Value\":\"2013-08-05\"},{\"Field\":\"20\",\"Operand\":\"0\",\"Value\":\"384843\"}]";
byte[] reqBody = System.Text.Encoding.ASCII.GetBytes(reqJSON);
req.GetRequestStream().Write(reqBody, 0, reqBody.Length);

//and here's the response stream.
HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
System.IO.StreamReader sr = new System.IO.StreamReader(resp.GetResponseStream());

 

 Example Response(JSON)

{"Activities":[{"AllDayEvent":false,"ClientID":384843,"ClientName":"Mary J Investor","Color":null,"EndDate":"\/Date(1375390800000-0700)\/","FontColor":null,"Importance":1,"LinkedNotesCount":0,"RecID":5000125,"Repeat":"False","StartDate":"\/Date(1375387200000-0700)\/","Subject":"CAI Needed","Type":"Task","TypeID":1},{"AllDayEvent":false,"ClientID":384843,"ClientName":"Mary J Investor","Color":null,"EndDate":"\/Date(1375909200000-0700)\/","FontColor":null,"Importance":1,"LinkedNotesCount":0,"RecID":5000136,"Repeat":"False","StartDate":"\/Date(1375903800000-0700)\/","Subject":"meet at clients house","Type":"2nd Meeting","TypeID":1044},"TotalRecords":1}
Was this article helpful?
1 out of 1 found this helpful
Have more questions? Submit a request

Comments

Powered by Zendesk