Skip to main content

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.

 

 

 

Hey @user1111​!

 

I spoke with our engineers and it would appear that the user ID you're passing isn't associated with any user in your Intercom workspace. Are you using the correct access token for the workspace in which this user is located?


Reply