Associating Integrations with Content
Problem
You want to associate an integration with a content item. See Associating and Using Multiple Integrations for an example using multiple integrations.
Updating the integrations associated with a piece of content replaces any existing associations with the newly supplied integrations.
Solution
Get a content item and an integration, then use the content item’s oauth.associations.update()
method to associate them.
from posit import connect
= "a080baef-854e-411f-ac3c-d2bc47bcb109"
CONTENT_GUID = "84f0f0ae-e328-44b0-98ba-aee6e775b5f0"
INTEGRATION_GUID
= connect.Client()
client = client.content.get(CONTENT_GUID)
content content.oauth.associations.update(INTEGRATION_GUID)
Get the connectapi
objects representing the piece of content and integration you wish to associate. Then, use the set_integrations()
function to apply the integration to the content item. You can pass in either a single integration object or a list of such objects.
library(jsonlite)
library(connectapi)
<- "a080baef-854e-411f-ac3c-d2bc47bcb109"
CONTENT_GUID <- "84f0f0ae-e328-44b0-98ba-aee6e775b5f0"
INTEGRATION_GUID
<- connect()
client
<- content_item(client, CONTENT_GUID)
content <- get_integration(client, INTEGRATION_GUID)
integration
set_integrations(content, integration)
Discussion
To view the newly created association follow the Finding Associations by Content recipe.
See also
- For more details about the data returned in this recipe, see List all OAuth integration associations for this content item in the API Reference.
- See OAuth Integrations in the User Guide to learn more about how publishers and viewers interact with OAuth integrations.
- See OAuth Integrations in the Admin Guide to for more detailed information on how to configure OAuth integrations.