CluedIn-io / CluedIn.Crawling.HubSpot

CluedIn HubSpot Crawler
1 stars 1 forks source link

Mesh generates an invalid curl command #48

Open jurgelionis opened 4 years ago

jurgelionis commented 4 years ago

Curl command gets generated here : https://github.com/CluedIn-io/CluedIn.Crawling.HubSpot/blob/a6db0bafbaf9242a7a9884569e5867d5d48b5ece/src/HubSpot.Provider/Mesh/Hubspot/HubspotUpdateBaseMeshProcessor.cs#L44 and https://github.com/CluedIn-io/CluedIn.Crawling.HubSpot/blob/a6db0bafbaf9242a7a9884569e5867d5d48b5ece/src/HubSpot.Provider/Mesh/Hubspot/HubspotContactMeshProcessor.cs#L8

Here's a curl command generated by this mesh implementation: curl -X PUT https://api.hubapi.com/contacts/v1/contact/vid/:vid/profile801?hapikey={{_-REMOVED-_}} --header "Content-Type: application/json" --data '{"properties":[{"name":"hubspot.contact.CompanyName","value":"DL Labbb"}]}'

https://api.hubapi.com/contacts/v1/contact/vid/:vid/profile801 is faulty, because :vid should be 801

If you look in here, :vid is not injected, but is taken literally.

A proper CURL command should look like this:

curl -X PUT https://api.hubapi.com/contacts/v1/contact/vid/801/profile?hapikey={{_-REMOVED-_}} --header "Content-Type: application/json" --data '{"properties":[{"name":"hubspot.contact.CompanyName","value":"DL Labbb"}]}'

kevinobee commented 4 years ago

@Hyldahl From the error information that @jurgelionis has provided on this we need to get the HubSpot CluedIn.Crawling.HubSpot.Core.Models.Vid field into the EditUrl being used by the CluedIn.Provider.HubSpot.Mesh.Hubspot.HubspotContactMeshProcessor.

From what I understand the :vid value in the Url used for editing needs to be replaces with the Hubspot Vid value from the Contact model in Hubspot repository. I can easily achieve that in the this method as I have the entity as a parameter:

public override List<RawQuery> GetRawQueries(IDictionary<string, object> config, IEntity entity, Core.Mesh.Properties properties)

From what I understand the GetRawQueries method is just used by the UI to display commands that would be executed against the HubSpot datastore.

The problem comes when I want to modify the Url in the following methods of the HubspotUpdateBaseMeshProcessor mesh processor.

public override List<QueryResponse> RunQueries(IDictionary<string, object> config, string id, Core.Mesh.Properties properties)

and

public override List<QueryResponse> Validate(ExecutionContext context, MeshDataCommand command, IDictionary<string, object> config, string id, MeshQuery query)

I am using the GetLookupId method that takes an IEntity parameter to return the code value that I believe relates to the HubSpot CluedIn.Crawling.HubSpot.Core.Models.Vid field

Can the id parameter passed into the RunQueries and Validate methods could potentially be used to locate the entity in the primary data store and then be used to derive the Mesh edit url for HubSpot?

Is what I have outlined a sensible approach to fixing this issue? If so how do I best I perform the data access necessary to retrieve the Entity based on the id parameters passed into the two problematic methods?

cluedindev commented 4 years ago

@kevinobee Can you book some time with me next week to go through this with you? I wrote this framework so probably would be better to work with on this one.

kevinobee commented 4 years ago

@kevinobee Can you book some time with me next week to go through this with you? I wrote this framework so probably would be better to work with on this one.

@cluedindev Yes that would be very helpful. Your calendar is likely much more constrained than mine so feel free to send me an invite to fit in best with you