Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Association Issue When Consuming Webservice #73

Open
mkumpf opened this issue Mar 3, 2016 · 3 comments
Open

Association Issue When Consuming Webservice #73

mkumpf opened this issue Mar 3, 2016 · 3 comments

Comments

@mkumpf
Copy link

mkumpf commented Mar 3, 2016

I have been struggling with consuming a particular webservice for some time now and have not been able to get it working. The webservice is from Hubspot. The returned JSON is as follows:

{
"contacts":[
{"addedAt":1454958537989,
"vid":1,
"canonical-vid":1,
"merged-vids":[],
"portal-id":2016447,
"is-contact":true,
"profile-token":"AO_T-mOPfmNESRoTf5_p1Q546HYy-3wmBbNdfVTZT9t3838HtAHNLQy4YR91m2oO4BypNJ2s5Mou75sLW_LiS8jtm01gaS2HiVBbV_9TvK3G-HRRGx07k7wUinGlgCX_ybwFuquBGf8Y","profile-url":"https://app.hubspot.com/contacts/2016447/lists/public/contact/_AO_T-mOPfmNESRoTf5_p1Q546HYy-3wmBbNdfVTZT9t3838HtAHNLQy4YR91m2oO4BypNJ2s5Mou75sLW_LiS8jtm01gaS2HiVBbV_9TvK3G-HRRGx07k7wUinGlgCX_ybwFuquBGf8Y/",
"properties":{
"firstname":{"value":"Brian"},
"lastmodifieddate":{"value":"1454959883325"},
"company":{"value":"Customer One"},
"lastname":{"value":"Humphrey"}},
"form-submissions":[],
"identity-profiles":[
{"vid":1,
"saved-at-timestamp":1454958536954,
"deleted-changed-timestamp":0,
"identities":[
{"type":"EMAIL",
"value":"[email protected]",
"timestamp":1454958536939},
{"type":"LEAD_GUID",
"value":"2abdbb41-8d96-4dfd-9060-7576ce71fff7",
"timestamp":1454958536945}]
}],
"merge-audits":[]}
],
"has-more":false,
"vid-offset":1}

I have modeled this in the domain model in the following way:

image

However, after having tried several different ways, I have not been successful at getting identity-profiles to deserialize into the Mendix domain model. I am likely doing something wrong....any pointers would be appreciated.

I have tried:

  • naming the association identity_profiles and putting an attribute called identity_profiles_jsonkey in both the Contact and Identity_ProfilesItem entities
  • naming the association _identity_profiles and adding and attribute called _identity_profiles_jsonkey to both entities
@mkumpf mkumpf changed the title Association Name Issue Association Issue When Consuming Webservice Mar 3, 2016
@tieniber
Copy link
Member

tieniber commented Mar 5, 2016

Mike,

You may have sorted this out already based on our email discussion, but if
you're using the mainline REST module you need to create the
identitity_profiles association as a - and you need to start the
association line from the Contact entity.

Hope that helps!
On Thu, Mar 3, 2016 at 7:00 AM mkumpf [email protected] wrote:

I have been struggling with consuming a particular webservice for some
time now and have not been able to get it working. The webservice is from
Hubspot. The returned JSON is as follows:

{
"contacts":[
{"addedAt":1454958537989,
"vid":1,
"canonical-vid":1,
"merged-vids":[],
"portal-id":2016447,
"is-contact":true,

"profile-token":"AO_T-mOPfmNESRoTf5_p1Q546HYy-3wmBbNdfVTZT9t3838HtAHNLQy4YR91m2oO4BypNJ2s5Mou75sLW_LiS8jtm01gaS2HiVBbV_9TvK3G-HRRGx07k7wUinGlgCX_ybwFuquBGf8Y","profile-url":"
https://app.hubspot.com/contacts/2016447/lists/public/contact/_AO_T-mOPfmNESRoTf5_p1Q546HYy-3wmBbNdfVTZT9t3838HtAHNLQy4YR91m2oO4BypNJ2s5Mou75sLW_LiS8jtm01gaS2HiVBbV_9TvK3G-HRRGx07k7wUinGlgCX_ybwFuquBGf8Y/
",
"properties":{
"firstname":{"value":"Brian"},
"lastmodifieddate":{"value":"1454959883325"},
"company":{"value":"Customer One"},
"lastname":{"value":"Humphrey"}},
"form-submissions":[],
"identity-profiles":[
{"vid":1,
"saved-at-timestamp":1454958536954,
"deleted-changed-timestamp":0,
"identities":[
{"type":"EMAIL",
"value":"[email protected]",
"timestamp":1454958536939},
{"type":"LEAD_GUID",
"value":"2abdbb41-8d96-4dfd-9060-7576ce71fff7",
"timestamp":1454958536945}]
}],
"merge-audits":[]}
],
"has-more":false,
"vid-offset":1}

I have modeled this in the domain model in the following way:

[image: image]
https://cloud.githubusercontent.com/assets/3680543/13496371/d127a436-e11d-11e5-9c7a-70d636e90891.png

However, after having tried several different ways, I have not been
successful at getting identity-profiles to deserialize into the Mendix
domain model. I am likely doing something wrong....any pointers would be
appreciated.

I have tried:

  • naming the association identity_profiles and putting an attribute
    called identity_profiles_jsonkey in both the Contact and
    Identity_ProfilesItem entities
  • naming the association _identity_profiles and adding and attribute
    called _identity_profiles_jsonkey to both entities


Reply to this email directly or view it on GitHub
#73.

@mkumpf
Copy link
Author

mkumpf commented Mar 6, 2016

Eric - thanks for the response. Based on our email discussion, I was able
to get past the previous error I was having. However, I still have one
question I am not sure about. In the case I mentioned here, there is an
association that is named identity-profiles in the json I receive. I think
I should name this association identity_profiles in my domain model. Is
the correct? Also, if this were an attribute, I would then put another
attribute called identity_profiles_jsonkey in the same entity with a
default value of identity-profiles so the REST module can properly
deserialize the attribute. However, in the case of an association, is the
same thing required? And if so, which entity do I put the
identity_profiles_jsonkey attribute in?

Thanks again,

Mike

On Sat, Mar 5, 2016 at 3:38 AM, tieniber [email protected] wrote:

Mike,

You may have sorted this out already based on our email discussion, but if
you're using the mainline REST module you need to create the
identitity_profiles association as a - and you need to start the
association line from the Contact entity.

Hope that helps!
On Thu, Mar 3, 2016 at 7:00 AM mkumpf [email protected] wrote:

I have been struggling with consuming a particular webservice for some
time now and have not been able to get it working. The webservice is from
Hubspot. The returned JSON is as follows:

{
"contacts":[
{"addedAt":1454958537989,
"vid":1,
"canonical-vid":1,
"merged-vids":[],
"portal-id":2016447,
"is-contact":true,

"profile-token":"AO_T-mOPfmNESRoTf5_p1Q546HYy-3wmBbNdfVTZT9t3838HtAHNLQy4YR91m2oO4BypNJ2s5Mou75sLW_LiS8jtm01gaS2HiVBbV_9TvK3G-HRRGx07k7wUinGlgCX_ybwFuquBGf8Y","profile-url":"

https://app.hubspot.com/contacts/2016447/lists/public/contact/_AO_T-mOPfmNESRoTf5_p1Q546HYy-3wmBbNdfVTZT9t3838HtAHNLQy4YR91m2oO4BypNJ2s5Mou75sLW_LiS8jtm01gaS2HiVBbV_9TvK3G-HRRGx07k7wUinGlgCX_ybwFuquBGf8Y/
",
"properties":{
"firstname":{"value":"Brian"},
"lastmodifieddate":{"value":"1454959883325"},
"company":{"value":"Customer One"},
"lastname":{"value":"Humphrey"}},
"form-submissions":[],
"identity-profiles":[
{"vid":1,
"saved-at-timestamp":1454958536954,
"deleted-changed-timestamp":0,
"identities":[
{"type":"EMAIL",
"value":"[email protected]",
"timestamp":1454958536939},
{"type":"LEAD_GUID",
"value":"2abdbb41-8d96-4dfd-9060-7576ce71fff7",
"timestamp":1454958536945}]
}],
"merge-audits":[]}
],
"has-more":false,
"vid-offset":1}

I have modeled this in the domain model in the following way:

[image: image]
<
https://cloud.githubusercontent.com/assets/3680543/13496371/d127a436-e11d-11e5-9c7a-70d636e90891.png

However, after having tried several different ways, I have not been
successful at getting identity-profiles to deserialize into the Mendix
domain model. I am likely doing something wrong....any pointers would be
appreciated.

I have tried:

  • naming the association identity_profiles and putting an attribute
    called identity_profiles_jsonkey in both the Contact and
    Identity_ProfilesItem entities
  • naming the association _identity_profiles and adding and attribute
    called _identity_profiles_jsonkey to both entities


Reply to this email directly or view it on GitHub
#73.


Reply to this email directly or view it on GitHub
#73 (comment).

@mweststrate
Copy link
Contributor

Hi @mkumpf,

Your assumption about the name identity_profiles for the association is correct. Note that the _jsonkey is only used by the RestModules for serialization, not for deserialization. But you can indeed have a _jsonkey attributes to alter the name of an association being serialized. It should be in the owning entity of the association.

Note that the complete serialization mechanism can be found here: https://github.com/mendix/RestServices/blob/master/javasource/restservices/util/JsonDeserializer.java

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants