CMS Block REST API: Get Magento 2 Block Content Using REST API

This article is all about the cms block page content, Today I will explain how you can get the Magento 2 CMS block content on the third-party server or another website using Magento 2 CMS block REST API.

Magento 2 CMS Block REST API for Get Data

If you will open the following file location in your Magento store then you will get all the list of cms block and cms page rest API.

Magento2_Installed_Directory/vendor/magento/Magento_Cms/etc/webapi.xml

Here you will get file content in something like this, So you just have to use this routing URL in order to get the cms block content data on your other website.

<route url="/V1/cmsBlock/:blockId" method="GET">
<service class="Magento\Cms\Api\BlockRepositoryInterface" method="getById"/>
<resources>
<resource ref="Magento_Cms::block"/>
</resources>
</route>

Now, just follow the step to get your Magento 2 store data content on your other website.

Here, this is the standard URL which we are going to hit, now you can change your block id as per your requirement and stores.

http://www.wishusucess.com/rest/all/V1/cmsBlock/blockId/

Rest: It's a type of API

All: It's a store id of your website

V1: it's a standard way of your route URL

Now the working URL will look something like the below URL.

http://www.wishusucess.com/rest/all/V1/cmsBlock/2

 

Magento 2 Admin Access Token Rest API

First, we have to get the admin access token by using Magento admin token API

https://wishusucess.com/rest/all/V1/integration/admin/token

Now you have to send the body content by using below payload

Payload:

{
"username": "Admin",
"password": "Admin@#123"
}

Method: POST

Now, just press the send button, then you will get the admin access token.

Magento 2 Admin Access Token

In the second step, you have to use the received admin access token in the postman header.

 

CMS Block REST API In Magento 2

Authorization: Bearer kmgupoopitbthwza5dkfm3srjfrtf1tb

content-type: application/json

Now send your request you will get the content of your Magento 2 cms block content of that particular block id.

http://www.wishusucess.com/rest/all/V1/cmsBlock/2

Magento 2 CMS Block REST API

Conclusion:

By using the above method you can get any kind of Magento 2 cms block content based on block id.

 

Related Post:

API Log Checker: How To Check Magento 2 Web API Log Details

Featured Product API: Get Featured Product Using Magento 2 REST API

 

Suggested Post:

Magento 2.4 Installation Guide: How to Install Magento 2.4.2

Leave a Reply