title: Microsoft TTS and Apache HttpRequest
body: <p>I am working with Microsoft Cognitive Services and submitting some TTS over the Rest API.  If I submit the xml listed below directly to the service via postman, it works fine, if I submit the xml below via my java code I get:</p>
  <blockquote>
  <p>HttpResponseProxy{HTTP/1.1 400 Synthesis failed. StatusCode: FailedPrecondition, Details: SSML parsing error: 8004507A. [Server: openresty/1.15.8.2, Date: Mon, 07 Jun 2021 20:48:40 GMT, Content-Type: text/xml, Transfer-Encoding: chunked, Connection: keep-alive, Strict-Transport-Security: max-age=15724800; includeSubDomains] ResponseEntityProxy{[Content-Type: text/xml,Chunked: true]}}</p>
  </blockquote>
  <p>The java code works flawlessly if I do not inject the SSML</p>
  <pre><code>&lt;phoneme alphabet=&quot;ipa&quot; ph=&quot;təˈmeɪtoʊ&quot;&gt; tomato &lt;/phoneme&gt;
  </code></pre>
  <p>The only thing I can think of going wrong is the Entity for the body.  With postman this is a raw body.  Is there something else I should be doing for the body in java?</p>
  <pre class="lang-java prettyprint-override"><code>HttpPost httpPost = new HttpPost(&quot;https://eastus.tts.speech.microsoft.com/cognitiveservices/v1&quot;);
  httpPost.setEntity(new StringEntity(xml));
  httpPost.addHeader(&quot;Content-Type&quot;, &quot;application/ssml+xml&quot;);
  httpPost.addHeader(&quot;Ocp-Apim-Subscription-Key&quot;, key);
  httpPost.addHeader(&quot;X-Microsoft-OutputFormat&quot;, &quot;audio-48khz-192kbitrate-mono-mp3&quot;);
  org.apache.http.HttpResponse resp = httpclient.execute(httpPost);
  </code></pre>
  <pre class="lang-xml prettyprint-override"><code>&lt;speak xmlns=&quot;http://www.w3.org/2001/10/synthesis&quot; xmlns:mstts=&quot;http://www.w3.org/2001/mstts&quot; xmlns:emo=&quot;http://www.w3.org/2009/10/emotionml&quot; version=&quot;1.0&quot; xml:lang=&quot;en-US&quot;&gt;&lt;voice name=&quot;en-US-JennyNeural&quot;&gt;&lt;mstts:express-as style=&quot;assistant&quot;&gt;&lt;prosody rate=&quot;5%&quot; pitch=&quot;13%&quot;&gt;
  we can totally get a &lt;phoneme alphabet=&quot;ipa&quot; ph=&quot;təˈmeɪtoʊ&quot;&gt; tomato &lt;/phoneme&gt; made for you right now!&lt;/prosody&gt;&lt;/mstts:express-as&gt;&lt;/voice&gt;&lt;/speak&gt;
  </code></pre>