Is Intercom API version 1.0 compatible with Intercom-dotnet SDK 2.1.1
Opened this issue · 0 comments
Here is the error we get:
Field Value @ingestionTime 1684822737054 @log 176772329757:/neptune/recruiter @logStream i-059a5b45e78383eae/192.168.102.69 @message { "message": "Exception of type 'Intercom.Exceptions.ApiException' was thrown.", "hashcode": 439432027, "source": "Library", "stackTrace": " at Intercom.Core.Client.Post[T](T body, Dictionary
2 headers, Dictionary2 parameters, String resource)\r\n at Intercom.Clients.EventsClient.Create(Event event)\r\n at Graylink.Neptune.RecruiterPortal.BasePage.SendIntercomEvent(String eventName, Dictionary
2 data) in C:\Workspaces\BitBucket\Neptune\neptune-.net\RecruiterPortal\Classes\BasePage.cs:line 509\r\n",
"link": null,
"file": null,
"line": "0",
"errornot_found": "User Not Found",
"statusDescription": "Not Found",
"responseBody": "{"type":"error.list","request_id":"004h01uqo3s6ait1fi20","errors":[{"code":"not_found","message":"User Not Found"}]}",
"tenantId": "telkom",
"host": "192.168.102.69",
"type": "DotNetException"
}
@timestamp
1684822737023
errornot_found
User Not Found
hashcode
439432027
host
192.168.102.69
line
0
message
Exception of type 'Intercom.Exceptions.ApiException' was thrown.
responseBody
{"type":"error.list","request_id":"004h01uqo3s6ait1fi20","errors":[{"code":"not_found","message":"User Not Found"}]}
source
Library
stackTrace
at Intercom.Core.Client.Post[T](T body, Dictionary2 headers, Dictionary
2 parameters, String resource)
at Intercom.Clients.EventsClient.Create(Event event)
at Graylink.Neptune.RecruiterPortal.BasePage.SendIntercomEvent(String eventName, Dictionary2 data) in C:\Workspaces\BitBucket\Neptune\neptune-.net\RecruiterPortal\Classes\BasePage.cs:line 509 statusDescription Not Found tenantId telkom type DotNetException
Here is the code we use:
`string accessToken = WebsiteContext.GetConfigurationFieldValue(WebsiteClass.WebsiteConfigurationFieldEnum.IntercomAccessToken);
if (string.IsNullOrWhiteSpace(accessToken) == false)
{
try
{
Intercom.Clients.EventsClient eventsclient = new Intercom.Clients.EventsClient(new Intercom.Core.Authentication(accessToken));
Intercom.Data.Event newEvent = new Intercom.Data.Event();
newEvent.created_at = (long)(DateTime.Now.Subtract(new DateTime(1970, 1, 1)).TotalSeconds);
if (SecurityContext.LoggedIn)
{
newEvent.user_id = SecurityContext.LoggedInUser.Email;
newEvent.email = SecurityContext.LoggedInUser.Email;
}
newEvent.event_name = eventName;
if (data != null)
{
Intercom.Data.Metadata eventData = new Intercom.Data.Metadata();
eventData.Add(data);
newEvent.metadata = eventData;
}
eventsclient.Create(newEvent);
}
catch (Intercom.Exceptions.ApiException apiEx)
{
Dictionary<string, string> errors = new Dictionary<string, string>();
foreach (Intercom.Data.Error err in apiEx.ApiErrors.errors)
{
errors.Add("error" + err.code, err.message);
}
errors.Add("statusDescription", apiEx.StatusDescription);
errors.Add("responseBody", apiEx.ApiResponseBody);
SecurityContext.Connection.ActiveDatabase.LogException(
apiEx,
errors
);
}
catch (Exception ex)
{
SecurityContext.Connection.ActiveDatabase.LogException(
ex,
new Dictionary<string, string>() { { "url", HttpContext.Current.Request.RawUrl } }
);
}
}`