How to update page content via the API


#1

Are there any examples of how to update page content via the API? While it is pretty straightforward to update properties like the name or slug, I am having trouble updating widgets.

If the retrieved page object looks like this:

{ "id": 5003111481,
   "name": "Page Test",
   "widget_containers": {
       "wizard_module_6942099579096154318": {
           "widgets": [
               { 
                  "body": {
                      "widget_type": "rich_text", 
                      "name": "wizard_module_-6083027123657618878", 
                      "is_widget_block": true,
                      "no_marker": true, 
                      "extra_wrapper_attrs": {}, 
                      "org_tag": "widget_block", 
                      "html": "Something Powerful", 
                      "label": "Rich Text", 
                      "parent_widget_container": "wizard_module_6942099579096154318", 
                      "no_wrapper": true, 
                      "overrideable": "true", 
                      "content_editable_values": ["html"], 
                      "smart_objects": [], 
                      "type": "rich_text"
                   }
               }
           ]
       }
   }
}

What arguments do you pass to PUT /content/api/v2/pages/$pageid to change the text in that widget, which currently reads “Something Powerful”?


#2

@maractwin there is an example on our docs!


#3

I’ve seen that example. It does not include any widget_containers, and that’s what I’ve discovered I can’t update. It looks like widgets disappear from the container if I don’t include them correctly, and I’m having trouble figuring out how to include them.


#4

Hey @pmanca,

How can I create pages using template and custom modules using API ?
Is there any way to create custom modules using API .


#5

@Amit_Kumar Next time please start your own thread. You can create templates through the API.

Right now there isn’t a way to just create a module through the API.