REST API: "Error 415 Unsupported Media Type"

お困りですか?

アトラシアン コミュニティをご利用ください。

コミュニティに質問

問題

When executing a REST API call, the following error is returned (using curl as an example):

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
<title>Error 415 Unsupported Media Type</title>
</head>
<body><h2>HTTP ERROR 415</h2>
<p>Problem accessing /rest/api/1.0/rest-service/reviews-v1. Reason:
<pre>    Unsupported Media Type</pre></p><hr /><i><small>Powered by Jetty://</small></i><br/>                                                
<br/>

In the atlassian-fisheye-yyyy-mm-dd.log the following stack-trace can be seen:

2012-12-10 14:19:37,263 ERROR [btpool0-2 ] com.atlassian.plugins.rest.common.error.jersey.ThrowableExceptionMapper ThrowableExceptionMapper-toResponse - Uncaught exception thrown by REST service
javax.ws.rs.WebApplicationException
	at com.sun.jersey.server.impl.uri.rules.TerminatingRule.accept(TerminatingRule.java:66)
	at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108)
	at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
	at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)
	at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1469)
	at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1400)
	at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1349)
(...)

原因

An incorrect "Content-Type" (eg.text/xml) or no "Content-Type" has been defined for the call.

ソリューション

The correct "Content-Type" should be indicated in the call:

curl -u admin:admin -X POST -d@cr.xml http://localhost:8060/rest-service/reviews-v1 -H "Content-Type: application/xml"

For more information over REST API please refer to the following documentation:



説明 This page discusses about an error while executing a REST API call when an incorrect "Content-Type" (eg.text/xml) or no "Content-Type" has been defined for the call.
製品 Fisheye, Crucible
最終更新日 2019 年 1 月 2 日

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.