CMS Development

gufoe
Member

How to set HubDB image value through API?

SOLVE

There is no documentation about how to set a image cell value through the HubDB API.

I managed to upload the file to the file manager and get its ID and URL.

But now I don't know how to use that into HubDB.

 

I tried many things, none worked.

 

I tried: a STRING url, it gives me 

[message] => error when updating datatable row 63392861046 in table 5315761 for portal 3077106: the value {type=string, value=} for column image was of type STRING, but we're expecting MAP

 

Then I tried with [ type => image, value => http:// ]  and many other combinations using both url, path, and ID.

No errors but nothing is set.

 

 

0 Upvotes
1 Accepted solution
JArechiga
Solution
Participant

How to set HubDB image value through API?

SOLVE

In addition to width and height, a type key with a value of image is also needed. For example if you're using JSON, here is a valid image object you can post with the API:

"image_property_name": {
  "url": "https://example.com/image.png",
  "width": 100,
  "height": 100,
  "type": "image"
}

 

View solution in original post

6 Replies 6
piersg
Key Advisor

How to set HubDB image value through API?

SOLVE

@gufoe ah sorry, I misunderstood. I think you have to pass it an object as a value, like so 

 

{"width": null, "height": null, "url": "[full url of image including https://]"}

 

as that's how images are represented in HubDB. A map is a dict, i.e. a set of key value pairs.

gufoe
Member

How to set HubDB image value through API?

SOLVE

Sorry for the late reply. This method is not working aswell.

I get the following error: error when updating datatable row 65217422972 in table 5297224 for portal 3077106: null

 

This is my request content for the column [


[width] => 10
[height] => 10
[url] => https://academy.dakota.eu/hubfs/On%20Page%20-%20section5-1.png
]

 

Any other idea?

0 Upvotes
gufoe
Member

How to set HubDB image value through API?

SOLVE

I tried passing null to width and height but I get the very same error

0 Upvotes
JArechiga
Solution
Participant

How to set HubDB image value through API?

SOLVE

In addition to width and height, a type key with a value of image is also needed. For example if you're using JSON, here is a valid image object you can post with the API:

"image_property_name": {
  "url": "https://example.com/image.png",
  "width": 100,
  "height": 100,
  "type": "image"
}

 

piersg
Key Advisor

How to set HubDB image value through API?

SOLVE

With an image column type you can just insert an image using the normal Hubspot image selector when editing the HubDB

piersg_0-1641835674084.png

piersg_1-1641835688833.png

 

Alternatively, if you want to point to a URL where an image is hosted instead of selecting one of your own images, use the URL column type and add the full address e.g. https://via.placeholder.com/350x150

gufoe
Member

How to set HubDB image value through API?

SOLVE

Sorry, I meant throught the API, not through the interface.

0 Upvotes