Skip to content

Instantly share code, notes, and snippets.

@ojmccall
Created September 25, 2021 05:56
Show Gist options
  • Save ojmccall/c284ff822ace66ce100b62c59d5aa27c to your computer and use it in GitHub Desktop.
Save ojmccall/c284ff822ace66ce100b62c59d5aa27c to your computer and use it in GitHub Desktop.
GCP - SFMC Find & Replace Section 4
for JSON in Actarray:
change = 0
if JSON["content"].find(oldName) >-1:
id = JSON["id"]
customerKey = JSON["customerKey"]
RawContent = JSON["content"]
content = RawContent.replace(oldName,newName)
data = {
"id": id,
"customerKey": customerKey,
"content": content
}
change += 1
contentChanged +=1
if change >0: #for each item where a change was made patch back into SFMC
url = "https://"+baseURL+".rest.marketingcloudapis.com/asset/v1/content/assets/"+str(id)
response = requests.patch(url, headers=head,data=data)
d = response.json()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment