0

我正在尝试使用 JSON 格式(使用 Chrome 的附加组件 Advanced Rest Api)在 Restful 服务器上执行 POST 请求。这是 JSON 字符串:(带有标头:Accept: application/json; Authorization: Basic ....)

{
"datecreated": 1355237359326,
"datemodified": 1355237359326,
"entrylocation": "Düdingen",
"entrydate": 1347351720000,
"entryduration": 11900,
"comment": "Random text",
"publicvisible": 2,
-
"coursetype": "Running track (Outdoor)",
"courselength": 600,
"numberofrounds": 12,
"track": "Fast track"
}

我收到以下错误:

Can not instantiate abstract type [simple type, class ch.unifr.cybercoach.server.entities.jaxb.entries.Entry] (need to add/enable type         information?) 
at [Source: org.eclipse.jetty.server.HttpInput@65ab8182; line: 1, column: 2]

这很奇怪,因为相同的 POST 请求适用于 XML 格式:

 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <entryrunning>
 <comment>Random text</comment>
 <entrydate>2012-09-11T10:22:00+02:00</entrydate>
 <entryduration>11900</entryduration>
 <entrylocation>Düdingen</entrylocation>
 <publicvisible>2</publicvisible>
 <courselength>600</courselength>
 <coursetype>Running track (Outdoor)</coursetype>
 <numberofrounds>12</numberofrounds>
 <track>
PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPGttbCB4bWxucz0iaHR0cDovL3d3dy5vcGVuZ2lzLm5ldC9rbWwvMi4yIj4KICA8RG9jdW1lbnQ+CiAgICAgICAgICA8L1BvbHlnb24+CiAgICAgICAgPC9QbGFjZW1hcms+CiAgICAgIDwvRm9sZGVyPgogICAgPC9Gb2xkZXI+CiAgPC9Eb2N1bWVudD4KPC9rbWw+Cg==</track>
 </entryrunning>

有人有什么想法吗?

提前谢谢了!

4

1 回答 1

0

sys.stderr 原来是正确的 - 谢谢(请参阅我的问题帖子下方的评论)。服务器端存在解组问题。现在这个问题已经解决了,下面的 json 字符串就可以正常工作了:

{"entryrunning" :{
"datecreated": 1355237359326,
"datemodified": 1355237359326,
"entrylocation": "Düdingen",
"entrydate": 1347351720000,
"entryduration": 11900,
"comment": "Random text",
"publicvisible": 2,
"coursetype": "Running track (Outdoor)",
"courselength": 600,
"numberofrounds": 12,
"track": "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPGttbCB4bWxucz0iaHR0cDovL3d3dy5vcGVuZ2lzLm5ldC9rbWwvMi4yIj4KICA8RG9jdW1lbnQ+CiAgICAgICAgICA8L1BvbHlnb24+CiAgICAgICAgPC9QbGFjZW1hcms+CiAgICAgIDwvRm9sZGVyPgogICAgPC9Gb2xkZXI+CiAgPC9Eb2N1bWVudD4KPC9rbWw+Cg=="
}}
于 2012-12-12T21:20:18.743 回答