Pregunta

I am attempting to send a push notification to both android and iOS using xtify. I am able to do this, however, the payload information doesn't appear to be working for me. If I remove the payload, the request succeeds, but adding the payload causes a server error. Can anyone look at the json I am sending and tell me if I am doing something wrong?

{
   "apiKey":"...",
   "appKey":"...",
   "xids":[
      "..."
   ],
   "content":{
      "subject":"chat from billy bob",
      "message":"hey",
      "payload":{
         "UserId":"1",
         "DeviceId":"9"
      }
   }
}

Here is the error the server returns: HTTP/1.1 500 Internal Server Error Date: Wed, 30 May 2012 22:51:51 GMT Content-Type: text/html;charset=utf-8 Content-Length: 5839 Connection: close

JBoss Web/2.1.3.GA - Error report

HTTP Status 500 -

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: org.codehaus.jackson.map.JsonMappingException: Can not deserialize instance of java.lang.String out of START_OBJECT token
at [Source: org.apache.catalina.connector.CoyoteInputStream@210c8d4e; line: 1, column: 199] (through reference chain: com.xtify.api.entities.PushRequest["content"]->com.xtify.api.entities.Content["payload"])
       com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:418)
       com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:537)
       com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:708)
       javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
       org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)

root cause

org.codehaus.jackson.map.JsonMappingException: Can not deserialize instance of java.lang.String out of START_OBJECT token
at [Source: org.apache.catalina.connector.CoyoteInputStream@210c8d4e; line: 1, column: 199] (through reference chain: com.xtify.api.entities.PushRequest["content"]->com.xtify.api.entities.Content["payload"])
       org.codehaus.jackson.map.JsonMappingException.from(JsonMappingException.java:163)
       org.codehaus.jackson.map.deser.StdDeserializationContext.mappingException(StdDeserializationContext.java:219)
       org.codehaus.jackson.map.deser.std.StringDeserializer.deserialize(StringDeserializer.java:44)
       org.codehaus.jackson.map.deser.std.StringDeserializer.deserialize(StringDeserializer.java:13)
       org.codehaus.jackson.map.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:299)
       org.codehaus.jackson.map.deser.SettableBeanProperty$MethodProperty.deserializeAndSet(SettableBeanProperty.java:414)
       org.codehaus.jackson.map.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:697)
       org.codehaus.jackson.map.deser.BeanDeserializer.deserialize(BeanDeserializer.java:580)
       org.codehaus.jackson.map.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:299)
       org.codehaus.jackson.map.deser.SettableBeanProperty$MethodProperty.deserializeAndSet(SettableBeanProperty.java:414)
       org.codehaus.jackson.map.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:697)
       org.codehaus.jackson.map.deser.BeanDeserializer.deserialize(BeanDeserializer.java:580)
       org.codehaus.jackson.map.ObjectMapper._readValue(ObjectMapper.java:2704)
       org.codehaus.jackson.map.ObjectMapper.readValue(ObjectMapper.java:1315)
       org.codehaus.jackson.jaxrs.JacksonJsonProvider.readFrom(JacksonJsonProvider.java:419)
       com.sun.jersey.json.impl.provider.entity.JacksonProviderProxy.readFrom(JacksonProviderProxy.java:139)
       com.sun.jersey.spi.container.ContainerRequest.getEntity(ContainerRequest.java:474)
       com.sun.jersey.server.impl.model.method.dispatch.EntityParamDispatchProvider$EntityInjectable.getValue(EntityParamDispatchProvider.java:123)
       com.sun.jersey.server.impl.inject.InjectableValuesProvider.getInjectableValues(InjectableValuesProvider.java:46)
       com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$EntityParamInInvoker.getParams(AbstractResourceMethodDispatchProvider.java:153)
       com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:203)
       com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75)
       com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:288)
       com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108)
       com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
       com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)
       com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1483)
       com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1414)
       com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1363)
       com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1353)
       com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:414)
       com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:537)
       com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:708)
       javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
       org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)

note The full stack trace of the root cause is available in the JBoss Web/2.1.3.GA logs.

JBoss Web/2.1.3.GA

¿Fue útil?

Solución

The element type is JSON and not an array. So the payload element should look like:

"payload": "{ 'key1' : 'value1', 'key2' : 'value2'} "

Give that a try and let me know how it works out.

Michael

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top