I am trying to implement the Intercom API into my server side .NET Core application. I am using System.Net.Http Library to set this call up. The issue that I am running into is when I try to create a conversation using my code below I keep getting an error response stating "User Not Found" even though the same body being passed in works perfectly fine POSTMAN. Is there anything I am doing wrong here?
Â
---------------------------------------------------------------------------------
Â
   public class Create
   {
       public FromObj From { get; set; }
       public string Subject { get; set; }
       public string Body { get; set; }
   }
Â
   public class FromObj
   {
       public string Type { get; set; }
       public string Id { get; set; }
   }
Â
public async Task CreateConversationBlah()
       {
           using (var client = HttpClient)
           {
               client.DefaultRequestHeaders.Authorization =
                   new AuthenticationHeaderValue("Bearer", "<APP TOKEN HERE>");
               client.DefaultRequestHeaders.Accept
                   .Add(new MediaTypeWithQualityHeaderValue("application/json"));
               client.DefaultRequestHeaders.TryAddWithoutValidation("Content-Type", "application/json");
Â
               var payload = new Create
               {
                   From = new FromObj
                   {
                       Id = "605e2f85b5e8becbbd8d6a71",
                       Type = "user"
                   },
                   Subject = "Hello can you hear me!",
                   Body = "Server side testing"
               };
Â
               // Serialize our concrete class into a JSON String
               var stringPayload = JsonConvert.SerializeObject(payload,
                   typeof(Create),
                   Formatting.None,
                   new JsonSerializerSettings
                   {
                       NullValueHandling = NullValueHandling.Ignore
                   });
Â
               // Wrap our JSON inside a StringContent which then can be used by the HttpClient class
               var httpContent = new StringContent(stringPayload);
               httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
Â
               var request = new HttpRequestMessage
               {
                   Method = HttpMethod.Post,
                   RequestUri = new Uri("https://api.intercom.io/conversationsquot;),
                   Content = httpContent
               };
Â
               //var httpResponse =
               //   await client.PostAsync("https://api.intercom.io/conversationsquot;, httpContent);
Â
               var httpResponse =
                   await client.SendAsync(request);
Â
               if (httpResponse.IsSuccessStatusCode)
               {
Â
               }
               else
               {
                   var content = await httpResponse.Content.ReadAsStringAsync();
               }
           }
       }
---------------------------------------------------------------------------------
Â
---------------------------------------------------------------------------------
{
    "type": "error.list",
    "request_id": "003uirsn0qu79bnhgb20",
    "errors": Â
        {
            "code": "not_found",
            "message": "User Not Found"
        }
    ]
}
---------------------------------------------------------------------------------
Â
Thanks in advance.
Â
Â
Â