【发布时间】:2015-03-30 11:42:34
【问题描述】:
我有两个 REST-GUI 来测试我的 REST 应用程序。 一个是用 swagger 创建的,另一个是在 Chrome 中运行的 Advanced REST Client。
我向服务发布帖子,Swagger 失败并出现错误 415,而 Advanced Rest Client 成功。
两者的区别在于请求头中的Content-Type。 OK 版本有 Content-Type: text/plain 错误版本有:Content-Type: application/json
对于其余部分,两者完全相同。我切断了有效载荷,但它们在两种情况下也完全相同。
我不知道如何在 Swagger 中更改 Content-Type,如果可能以及是否需要。
以下是您在此问题上可能需要帮助我的信息。如果您需要更多信息,请需要。
非常感谢您的帮助。
最好的问候。
信息如下:
确定:高级 REST 客户端
Remote Address:127.0.0.1:8080
Request URL:http://localhost:8080/oak-kernel-2.0/oak/archetype
Request Method:POST
Status Code:200 OK
POST /oak-kernel-2.0/oak/archetype HTTP/1.1
Host: localhost:8080
Connection: keep-alive
Content-Length: 10642
Origin: chrome-extension://hgmloofddffdnphfgcellkdfbfbjeloo
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 ....
Content-Type: text/plain
Accept: */*
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.8,nl;q=0.6
Cookie: _ga=GA1.1.1597438054.1422608427
有效载荷(片段):
{"archetype": "archetype (adl_version\u003d1.4)\n\top........
回复:
Accept-Ranges:bytes
Content-Length:87
Content-Type:application/json;charset=UTF-8
Date:Fri, 30 Jan 2015 20:59:49 GMT
Server:Restlet-Framework/2.2.3
Vary:Accept-Charset, Accept-Encoding, Accept-Language, Accept
错误:大摇大摆
Remote Address:127.0.0.1:8080
Request URL:http://localhost:8080/oak-kernel-2.0/oak/archetype
Request Method:POST
Status Code:415 Unsupported Media Type
POST /oak-kernel-2.0/oak/archetype HTTP/1.1
Host: localhost:8080
Connection: keep-alive
Content-Length: 10642
Accept: application/json
Origin: http://localhost:8080
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 ....
Content-Type: application/json
Referer: http://localhost:8080/swagger/
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.8,nl;q=0.6
Cookie: _ga=GA1.1.1597438054.1422608427
有效载荷(片段):
{"archetype": "archetype (adl_version\u003d1.4)\n\top........
回应
Accept-Ranges:bytes
Content-Length:554
Content-Type:text/html;charset=UTF-8
Date:Fri, 30 Jan 2015 21:28:12 GMT
Server:Restlet-Framework/2.2.3
【问题讨论】:
标签: java json rest content-type swagger-ui