2

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

tboling1
  • 488
  • 4
  • 13

1 Answers1

2

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

Michael Bordash
  • 1,072
  • 1
  • 10
  • 20
  • Hi Michael. That worked well. Everything is working on android. However, we are still having an issue on iphone. Our userInfo dictionary that is passed with didReceiveRemoteNotification doesn't contain any of the payload data. Is it possible to send payload data to iPhone? Is there something special we need to do to retrieve it? Thanks again for your help – tboling1 May 31 '12 at 22:09
  • Hmmm... I'll need to take a closer look. On first test, I also didn't get the payload down on my iphone test app. – Michael Bordash Jun 03 '12 at 02:12
  • Hi, payload is only valid for c2dm. For iOS, you can send down custom json via the data value in the action sub document. I'll make sure that the documentation is clear on our dev portal. – Michael Bordash Jun 04 '12 at 23:07
  • Hi Michael, xtify's server accepted the call, but our dictionary for didReceiveNotification still doesn't have custom data. Here is the json we are sending. I assume this is what you meant by the data value in the action sub document? Any ideas? { "apiKey":"...", "appKey":"...", "xids":[ ".." ], "content":{ "subject":"Chat From", "message":"Go ahead, make my day.", "action":{ "data":"{\"UserId\":\"1\",\"DeviceId\":\"9\",\"Message\":\"hey\"}" }, "payload":null } Thanks for your help. – tboling1 Jun 04 '12 at 23:24
  • The documents were updated and are much more helpful now. Thank you. I had to specifiy Custom type for my action as well. After that change everything starting working. Thanks for all your help. – tboling1 Jun 04 '12 at 23:32