<?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: Wrong content type in REST-API in Alfresco Archive</title>
    <link>https://connect.hyland.com/t5/alfresco-archive/wrong-content-type-in-rest-api/m-p/187763#M140893</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Wow, thanks for this detailed solution!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 26 Mar 2015 07:58:59 GMT</pubDate>
    <dc:creator>b_schnarr</dc:creator>
    <dc:date>2015-03-26T07:58:59Z</dc:date>
    <item>
      <title>Wrong content type in REST-API</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/wrong-content-type-in-rest-api/m-p/187761#M140891</link>
      <description>Hello at all,when you invoke the Activiti REST-API runtime/process-instances/{process-instance-id}/diagram‍, the content-type set by the REST-API is text/html‍. That leads to the problem that the diagram (png) can not be displayed in the browser because the browser only displays the raw-content of t</description>
      <pubDate>Wed, 25 Mar 2015 10:19:41 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/wrong-content-type-in-rest-api/m-p/187761#M140891</guid>
      <dc:creator>b_schnarr</dc:creator>
      <dc:date>2015-03-25T10:19:41Z</dc:date>
    </item>
    <item>
      <title>Re: Wrong content type in REST-API</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/wrong-content-type-in-rest-api/m-p/187762#M140892</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Spring MVC uses the request's Accept header to set the response content type. When a request to the diagram is made from an IMG HTML tag the header will look something like&lt;/SPAN&gt;&lt;BR /&gt;&lt;CODE&gt;&lt;BR /&gt;Accept: image/png,image/*;q=0.8,*/*;q=0.5&lt;BR /&gt;&lt;/CODE&gt;&lt;BR /&gt;&lt;SPAN&gt;Which will produce a response of content type image/png. But when trying to access the image directly the request's Accept header will look something like &lt;/SPAN&gt;&lt;BR /&gt;&lt;CODE&gt;&lt;BR /&gt;Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 &lt;BR /&gt;&lt;/CODE&gt;&lt;BR /&gt;&lt;SPAN&gt;Which produces a response of content type text/html. Although, the code in getProcessInstanceDiagram sets the content type of the response to image/png&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[java]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;response.setContentType("image/png");&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[/java]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;That won't work since Spring MVC will change it afterwards depending on the request's Accept header. To force the response header to always be image/png the produces attribute can be used in the @RequestMapping annotation as follows&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[java]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;@RequestMapping(value="/runtime/process-instances/{processInstanceId}/diagram", method = RequestMethod.GET, produces="image/png")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[/java]&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Mar 2015 04:05:14 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/wrong-content-type-in-rest-api/m-p/187762#M140892</guid>
      <dc:creator>balsarori</dc:creator>
      <dc:date>2015-03-26T04:05:14Z</dc:date>
    </item>
    <item>
      <title>Re: Wrong content type in REST-API</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/wrong-content-type-in-rest-api/m-p/187763#M140893</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Wow, thanks for this detailed solution!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Mar 2015 07:58:59 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/wrong-content-type-in-rest-api/m-p/187763#M140893</guid>
      <dc:creator>b_schnarr</dc:creator>
      <dc:date>2015-03-26T07:58:59Z</dc:date>
    </item>
    <item>
      <title>Re: Wrong content type in REST-API</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/wrong-content-type-in-rest-api/m-p/187764#M140894</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Actually, I'm glad that you brought up this issue. I faced this issue a couple of months ago and was planning to submit a pull for a fix but forgot to do that. So, thanks for reminding me &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://connect.hyland.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This issue doesn't appear in tests since requests do not include Accept headers, therefore, Spring MVC will not alter the response content type.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Additionally, using the produces attribute of @RequestMapping annotation doesn't handle cases when trying to access a non-existing process instance diagram or when an exception is thrown. The response in those cases will be an ugly 'HTTP Status 500' page error instead of a json formatted response. A better solution could be using Spring MVC's ResponseEntity class.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am working on a fix and will submit it a pull request soon.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Mar 2015 00:36:42 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/wrong-content-type-in-rest-api/m-p/187764#M140894</guid>
      <dc:creator>balsarori</dc:creator>
      <dc:date>2015-03-27T00:36:42Z</dc:date>
    </item>
    <item>
      <title>Re: Wrong content type in REST-API</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/wrong-content-type-in-rest-api/m-p/187765#M140895</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Here is the pull request&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://github.com/Activiti/Activiti/pull/556" rel="nofollow noopener noreferrer"&gt;https://github.com/Activiti/Activiti/pull/556&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Mar 2015 02:41:54 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/wrong-content-type-in-rest-api/m-p/187765#M140895</guid>
      <dc:creator>balsarori</dc:creator>
      <dc:date>2015-03-27T02:41:54Z</dc:date>
    </item>
  </channel>
</rss>

