<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Please Help: Error:The remote server returned an error: (415) Unsupported Media Type. in APIs &amp; Integrations</title>
    <link>https://community.hubspot.com/t5/APIs-Integrations/Please-Help-Error-The-remote-server-returned-an-error-415/m-p/429813#M42723</link>
    <description>&lt;P&gt;your content-type is application/json but you are sending string data&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;string json = JsonConvert.SerializeObject(NoteMain, Formatting.None);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;StreamWriter myWriter = new StreamWriter(objRequest.GetRequestStream(), Encoding.ASCII);&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;myWriter.Write(json);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;in your code json variable is a string type, but API endpoint accept application/json format&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 21 Apr 2021 09:38:40 GMT</pubDate>
    <dc:creator>kaleemmolani</dc:creator>
    <dc:date>2021-04-21T09:38:40Z</dc:date>
    <item>
      <title>Please Help: Error:The remote server returned an error: (415) Unsupported Media Type.</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Please-Help-Error-The-remote-server-returned-an-error-415/m-p/429600#M42704</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I am trying to run C# to submit information into our API. However, we keep getting the following error:&amp;nbsp;&lt;STRONG&gt;Message Returned:&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;Error:The remote server returned an error: (415) Unsupported Media Type.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Obviously we are missing something in the code. Any ideas? Of course, any confidential information is redacted &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;private string APIKey = "&amp;lt;HIDDEN&amp;gt;";&lt;BR /&gt;private string sNotesUrl = "&lt;A href="https://api.hubapi.com/crm/v3/objects/contacts/" target="_blank" rel="noopener"&gt;https://api.hubapi.com/crm/v3/objects/contacts/&lt;/A&gt;";&lt;/P&gt;
&lt;P&gt;private bool CreateCallNote(DateTime dActivityDate, string sDesc, string sSubject, string sPSID, string sDirection, string sDisp)&lt;BR /&gt;{&lt;BR /&gt;&lt;BR /&gt;bool result = true;&lt;BR /&gt;// build json&lt;BR /&gt;&lt;BR /&gt;ServiceLogger.Log(sLogFile, "Creating Temp Classes");&lt;BR /&gt;ServiceLogger.Log(sLogFile, "Creating Note Object:");&lt;BR /&gt;LeadNote NoteMain = new LeadNote();&lt;BR /&gt;ServiceLogger.Log(sLogFile, "Setting ID:" + skStudent);&lt;BR /&gt;NoteMain.Vendorid = Int32.Parse(skStudent);&lt;/P&gt;
&lt;P&gt;ServiceLogger.Log(sLogFile, "Setting Description:");&lt;BR /&gt;NoteMain.description = sDesc;&lt;BR /&gt;ServiceLogger.Log(sLogFile, "Survcode:");&lt;BR /&gt;NoteMain.survcode = sSurvcode;&lt;BR /&gt;ServiceLogger.Log(sLogFile, "Disp Time:");&lt;BR /&gt;NoteMain.lastdispositioned = dActivityDate.ToShortDateString();&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;sURLOut = sNotesUrl;&lt;/P&gt;
&lt;P&gt;ServiceLogger.Log(sLogFile, "Sending Up Json I hope:" + NoteMain.ToString());&lt;/P&gt;
&lt;P&gt;string json = JsonConvert.SerializeObject(NoteMain, Formatting.None);&lt;BR /&gt;json="{\"properties\":" +json + "}";&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;ServiceLogger.Log(sLogFile, "Bare String:" + json);&lt;BR /&gt;// Transmist and get results&lt;BR /&gt;WebRequest objRequest;&lt;/P&gt;
&lt;P&gt;ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;&lt;BR /&gt;objRequest = WebRequest.Create(sURLOut + sClientid + @"?hapikey=" + APIKey);&lt;/P&gt;
&lt;P&gt;objRequest.Method = "PATCH";&lt;BR /&gt;objRequest.ContentLength = json.Length;&lt;BR /&gt;objRequest.ContentType = "application/json'";&lt;BR /&gt;StreamWriter myWriter = new StreamWriter(objRequest.GetRequestStream(), Encoding.ASCII);&lt;BR /&gt;myWriter.Write(json);&lt;/P&gt;
&lt;P&gt;myWriter.Close();&lt;BR /&gt;WebResponse objResponse = objRequest.GetResponse();&lt;BR /&gt;StreamReader sr;&lt;BR /&gt;Encoding encode = System.Text.Encoding.GetEncoding("utf-8");&lt;BR /&gt;sr = new StreamReader(objResponse.GetResponseStream(), Encoding.ASCII);&lt;BR /&gt;string strresult = "";&lt;BR /&gt;strresult = sr.ReadToEnd();&lt;BR /&gt;ServiceLogger.Log(sLogFile, "Posted Response:" + strresult);&lt;BR /&gt;strresult = strresult.ToUpper();&lt;BR /&gt;strresult = strresult.Trim();&lt;BR /&gt;&lt;BR /&gt;return (result);&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;public class LeadNote&lt;BR /&gt;{&lt;BR /&gt;public int Vendorid { get; set; }&lt;BR /&gt;public string survcode { get; set; }&lt;BR /&gt;public string description { get; set; } &lt;BR /&gt;public string lastdispositioned { get; set; }&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;json passed&lt;BR /&gt;{"properties":{"Vendorid":999999,"survcode":"TEST","description":"Testing Call Result","lastdispositioned":"4/19/2021"}}&lt;/P&gt;
&lt;P&gt;Message Returned:&lt;BR /&gt;Error:The remote server returned an error: (415) Unsupported Media Type.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Apr 2021 18:25:12 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Please-Help-Error-The-remote-server-returned-an-error-415/m-p/429600#M42704</guid>
      <dc:creator>StefaniUAT</dc:creator>
      <dc:date>2021-04-20T18:25:12Z</dc:date>
    </item>
    <item>
      <title>Re: Please Help: Error:The remote server returned an error: (415) Unsupported Media Type.</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Please-Help-Error-The-remote-server-returned-an-error-415/m-p/429813#M42723</link>
      <description>&lt;P&gt;your content-type is application/json but you are sending string data&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;string json = JsonConvert.SerializeObject(NoteMain, Formatting.None);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;StreamWriter myWriter = new StreamWriter(objRequest.GetRequestStream(), Encoding.ASCII);&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;myWriter.Write(json);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;in your code json variable is a string type, but API endpoint accept application/json format&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Apr 2021 09:38:40 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Please-Help-Error-The-remote-server-returned-an-error-415/m-p/429813#M42723</guid>
      <dc:creator>kaleemmolani</dc:creator>
      <dc:date>2021-04-21T09:38:40Z</dc:date>
    </item>
    <item>
      <title>Re: Please Help: Error:The remote server returned an error: (415) Unsupported Media Type.</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Please-Help-Error-The-remote-server-returned-an-error-415/m-p/430686#M42796</link>
      <description>&lt;P&gt;Thank you! Turns out we also had to change to byte? Strange but thanks for your help!&lt;/P&gt;</description>
      <pubDate>Thu, 22 Apr 2021 23:35:03 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Please-Help-Error-The-remote-server-returned-an-error-415/m-p/430686#M42796</guid>
      <dc:creator>StefaniUAT</dc:creator>
      <dc:date>2021-04-22T23:35:03Z</dc:date>
    </item>
    <item>
      <title>Re: Please Help: Error:The remote server returned an error: (415) Unsupported Media Type.</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Please-Help-Error-The-remote-server-returned-an-error-415/m-p/502356#M47261</link>
      <description>&lt;P&gt;Can you please say how you solved this problem? What modifications did you make to the code?&lt;/P&gt;</description>
      <pubDate>Wed, 29 Sep 2021 02:42:00 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Please-Help-Error-The-remote-server-returned-an-error-415/m-p/502356#M47261</guid>
      <dc:creator>VMorris</dc:creator>
      <dc:date>2021-09-29T02:42:00Z</dc:date>
    </item>
  </channel>
</rss>

