Execute Content Hub Script using Postman

Sitecore Content Hub provides a script editor feature to write custom scripts and perform our business logic. Depending on the type of script and use cases, we can trigger the script manually or automatically using triggers. In this blog post, I am explaining how to execute the script manually using Postman. To execute the script from Postman, you need the Script URL and X-Auth-Token. Go to the Content Hub dashboard using the manage icon and click on the Script icon:

script-execute-postman-1

It will open a Scripts page window, click on add new script icon:

script-execute-postman-2

In the popup window, provide the Name and Type of the script and click save, I am choosing Action type here:

script-execute-postman-3

Search your script in the Script window and click on the script name, it will open the script editor to write a script:

script-execute-postman-4

Click on the Edit icon write the custom script and save the changes button:

script-execute-postman-5

Click on the Build button, it builds your scripts and lets you know about the build status in the build output whether its build is successful or an error.

script-execute-postman-6

Once the build is successful, click on the Publish button and it publishes your script and is ready to use and execute. 

Go back to the script on the Script window, enable the script, and from more action click on the Share URL option and copy the URL:

script-execute-postman-7

Next, you need an X-Auth-Token. Go to the Content Hub dashboard, choose the Users option, search your name in the User window, click on the key icon, and create a token for you. 

script-execute-postman-8

Now you have the Script URL and X-Auth-Token to execute the script. Open Postman, paste the URL, add two keys and values in the header section as follows, and execute the script.

script-execute-postman-9

To verify the result, go to the Content Hub Script window click on more details, and choose the View logs option:

script-execute-postman-10 script-execute-postman-11

Happy Sitecoreing ðŸ˜Š

Comments

Popular posts from this blog

Sitecore Installation Error: Failed to Start Service 'Sitecore Marketing Automation Engine'

Import CSV Data in Sitecore Using PowerShell: Part-3

Sitecore : The database principal owns a schema in the database, and cannot be dropped message