AnsweredAssumed Answered

Get Activities doesn't show Results

Question asked by f07a663528bf4e2405fdb4c22d5c900ab1498834 on May 4, 2018
Latest reply on May 4, 2018 by Sanford Whiteman

Hi guys,

 

I'm trying to get Interesting Moments acitivities using the REST API. But the json response is not returning Results, can you guys help me please?

The activityType is 46, I have requested the types previously.

 

String url = host + "/rest/v1/activities.json?access_token=" + getToken() + "&activityTypeIds=" + activityType + "&nextPageToken=" + nextPageToken;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Method = "GET";
request.ContentType = "application/json";
request.Accept = "application/json";

HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream resStream = response.GetResponseStream();
StreamReader reader = new StreamReader(resStream);
var result = reader.ReadToEnd();

 

And this is the response:

{"requestId":"271a#1632ca3a6a1","success":true,"nextPageToken":"4GAX7YNCIJKO2VAED5LH5PQIYO46Y4DV52DUUR5BJRFEATLBK2MA====","moreResult":true}

 

getToken()

private String getToken()
{
   String url = host + "/identity/oauth/token?grant_type=client_credentials&client_id=" + clientId + "&client_secret=" + clientSecret;

   String result = getData(url);
   Dictionary<String, String> dict = JsonConvert.DeserializeObject<Dictionary<String, String>>(result);
   return dict["access_token"];
}

 

nextPageToken

String pagingTokenObj = getPagingToken("2017-01-01T00:00:00-00:00");

private String getPagingToken(string sinceDatetime)
{
   String url = host + "/rest/v1/activities/pagingtoken.json?access_token=" + getToken() + "&sinceDatetime=" + sinceDatetime;

   String result = getData(url);
   return result;
}

 

getData()

private String getData(string url)
{
   String data = string.Empty;

try
{
   HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
   request.Method = "GET";
   request.ContentType = "application/json";
   request.Accept = "application/json";

   HttpWebResponse response = (HttpWebResponse)request.GetResponse();
   Stream resStream = response.GetResponseStream();
   StreamReader reader = new StreamReader(resStream);
   var result = reader.ReadToEnd();

   if (response.StatusCode.ToString() == "OK")
   {
      data = result;
   }
   else
   {
      Console.WriteLine(response.StatusCode.ToString());
      data = "Status:" + response.StatusCode.ToString();
   }
}
catch (Exception ex)
{
   Console.WriteLine(ex.Message);
}

   return data;
}




Outcomes