force-rest-api icon indicating copy to clipboard operation
force-rest-api copied to clipboard

UnrecognizedPropertyException

Open edgartff opened this issue 8 years ago • 8 comments

Hello,

I followed the instructions in the README file in order to make a call to get an Account object and I received the following error. Is this a bug or am I doing something wrong?

2017-09-20 20:31:35,559 ERROR [http-nio-8080-exec-10] GrailsExceptionResolver - UnrecognizedPropertyException occurred when processing request: [GET] /api/test/testSalesforce Unrecognized field "attributes" (class com.test.Account), not marked as ignorable (6 known properties: "tffAccountNumber", "metaClass", "externalId", "id", "name", "annualRevenue"]) at [Source: sun.net.www.protocol.http.HttpURLConnection$HttpInputStream@68b2688d; line: 1, column: 16] (through reference chain: com.test.Account["attributes"]). Stacktrace follows: com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "attributes" (class com.test.Account), not marked as ignorable (6 known properties: "tffAccountNumber", "metaClass", "externalId", "id", "name", "annualRevenue"]) at [Source: sun.net.www.protocol.http.HttpURLConnection$HttpInputStream@68b2688d; line: 1, column: 16] (through reference chain: com.test.Account["attributes"]) at com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException.from(UnrecognizedPropertyException.java:51) at com.fasterxml.jackson.databind.DeserializationContext.reportUnknownProperty(DeserializationContext.java:817) at com.fasterxml.jackson.databind.deser.std.StdDeserializer.handleUnknownProperty(StdDeserializer.java:954) at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownProperty(BeanDeserializerBase.java:1324) at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownVanilla(BeanDeserializerBase.java:1302) at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:249) at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:136) at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3562) at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2648) at com.force.api.ResourceRepresentation.as(ResourceRepresentation.java:31) at com.test.TestController$$EQVncaRc.testSalesforce(TestController.groovy:116) at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:198) at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63) at net.bull.javamelody.JspWrapper.invoke(JspWrapper.java:150) at net.bull.javamelody.JdbcWrapper$DelegatingInvocationHandler.invoke(JdbcWrapper.java:286) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:201) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:178) at grails.plugin.springsecurity.web.filter.GrailsAnonymousAuthenticationFilter.doFilter(GrailsAnonymousAuthenticationFilter.java:53) at grails.plugin.springsecurity.rest.RestAuthenticationFilter.doFilter(RestAuthenticationFilter.groovy:139) at grails.plugin.springsecurity.web.authentication.RequestHolderAuthenticationFilter.doFilter(RequestHolderAuthenticationFilter.java:53) at grails.plugin.springsecurity.web.authentication.logout.MutableLogoutFilter.doFilter(MutableLogoutFilter.java:62) at grails.plugin.springsecurity.rest.RestLogoutFilter.doFilter(RestLogoutFilter.groovy:80) at com.AssetFilter.doFilter(AssetFilter.groovy:55) at com.security.XssFilter.doFilterInternal(XssFilter.groovy:17) at grails.plugin.databasesession.SessionProxyFilter.doFilterInternal(SessionProxyFilter.java:60)

edgartff avatar Sep 20 '17 20:09 edgartff

Have you tried adding

@JsonIgnoreProperties(ignoreUnknown = true)

As a class annotation on com.test.Account?

jesperfj avatar Sep 25 '17 16:09 jesperfj

Thanks Jesper. I did try that, and strangely, it still throws an error.

Sent from my iPhone

On Sep 25, 2017, at 9:23 AM, Jesper Joergensen <[email protected]mailto:[email protected]> wrote:

Have you tried adding

@JsonIgnoreProperties(ignoreUnknown = true)

As a class annotation on com.test.Account?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/jesperfj/force-rest-api/issues/49#issuecomment-331935380, or mute the threadhttps://github.com/notifications/unsubscribe-auth/Aa9mQL5S66vZQgJIZcE7jzRXEy4xmJKbks5sl9N2gaJpZM4Pecuj.

edgartff avatar Sep 25 '17 17:09 edgartff

Also, do you plan on every adding the DTO objects as part of the library?

-- Edgar

From: Jesper Joergensen <[email protected]mailto:[email protected]> Reply-To: jesperfj/force-rest-api <[email protected]mailto:[email protected]> Date: Monday, September 25, 2017 at 9:23 AM To: jesperfj/force-rest-api <[email protected]mailto:[email protected]> Cc: Edgar Castanedo <[email protected]mailto:[email protected]>, Author <[email protected]mailto:[email protected]> Subject: Re: [jesperfj/force-rest-api] UnrecognizedPropertyException (#49)

Have you tried adding

@JsonIgnoreProperties(ignoreUnknown = true)

As a class annotation on com.test.Account?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/jesperfj/force-rest-api/issues/49#issuecomment-331935380, or mute the threadhttps://github.com/notifications/unsubscribe-auth/Aa9mQL5S66vZQgJIZcE7jzRXEy4xmJKbks5sl9N2gaJpZM4Pecuj.

edgartff avatar Sep 25 '17 18:09 edgartff

Which API version are you using? I am getting similar (but not necessarily same) errors when running tests with API version 40.

jesperfj avatar Sep 25 '17 22:09 jesperfj

I am sorry but I can you clarify your question on DTO objects?

jesperfj avatar Sep 26 '17 04:09 jesperfj

Oh sure. I just meant objects like account, lead, contact, etc. So that we don’t have to create them.

Sent from my iPhone

On Sep 25, 2017, at 9:26 PM, Jesper Joergensen <[email protected]mailto:[email protected]> wrote:

I am sorry but I can you clarify your question on DTO objects?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/jesperfj/force-rest-api/issues/49#issuecomment-332082909, or mute the threadhttps://github.com/notifications/unsubscribe-auth/Aa9mQOMDsgKTGQF7WYI_FJUlQ00ocDPTks5smHzXgaJpZM4Pecuj.

edgartff avatar Sep 26 '17 06:09 edgartff

I see.

No. It is explicitly not in scope for this project to maintain class representations of those objects. My hope is to make force-rest-api interoperate seamlessly with other projects that seek to autogenerate and maintain class representations of various Salesforce projects.

jesperfj avatar Sep 26 '17 06:09 jesperfj

Thanks Jesper. I did try that, and strangely, it still throws an error. Sent from my iPhone On Sep 25, 2017, at 9:23 AM, Jesper Joergensen <[email protected]mailto:[email protected]> wrote: Have you tried adding @JsonIgnoreProperties(ignoreUnknown = true) As a class annotation on com.test.Account? — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub<#49 (comment)>, or mute the threadhttps://github.com/notifications/unsubscribe-auth/Aa9mQL5S66vZQgJIZcE7jzRXEy4xmJKbks5sl9N2gaJpZM4Pecuj.

@edgartff I faced the same issue, due to the code recommendation suggested by my IDE. My mapper class was fasterxml.jackson but the IDE imported codehaus.jackson which conflicted with the @JsonProperty annotation.

sreekeshd avatar Oct 18 '18 16:10 sreekeshd