1

I'm trying to obtain the publishedUrl of every CloudPage published.

With this script:

    <script runat="server">
  
  // Load the Core Library
  Platform.Load("core", "1.1");
  
  // Create a WSProxy Object
  var prox = new Script.Util.WSProxy();
  
  var cols = [
        "ID",
        "CustomerKey",
        "Name",
        "fileProperties.publishedURL"
        ];
  var filter =  {
    Property: "assetType.id",
    SimpleOperator: "in",
    Value: [205, 206]
  }
  
  var results = prox.retrieve("Asset", cols, filter);

  Write(Stringify(results.Results));
</script>  

I am reciving a json (converted in text) where all the fields that are objects appear as null. I can filter with the fields contained in that objects but I can't extract them.

Here is an example of the results:

[{"ContentType":"text/html","Version":1,"Locked":null,"Name":"testes","Description":null,"ActiveDate":null,"ExpirationDate":null,"MemberId":......,"EnterpriseId":....,"CreatedBy":null,"ModifiedBy":null,"Content":null,"Design":null,"SuperContent":null,"MinBlocks":null,"MaxBlocks":null,"File":null,"AssetType":null,"Status":null,"Thumbnail":null,"GenerateFrom":null,"Template":null,"Category":null,"Data":null,"FileProperties":null,"Meta":null,"CustomFields":null,"SharingProperties":null,"Views":null,"Blocks":null,"Slots":null,"Channels":null,"AllowedBlocks":null,"Tags":null,"Attributes":null,"Client":null,"PartnerKey":null,"PartnerProperties":null,"CreatedDate":"2020-09-24T05:12:21.557","ModifiedDate":"2020-09-28T03:23:40.280","ID":....,"ObjectID":".....","CustomerKey":".....","Owner":null,"CorrelationID":null,"ObjectState":null,"IsPlatformObject":false}]

Is there anything I can do to obtain a field inside one of those fields that are resulting like null? fileProperties is the objective, but once get one I will have full access to the info

Thank you

4
  • 2
    Unfortunately, you won't be able to get that info programmatically
    – zuzannamj
    Sep 30, 2020 at 13:45
  • So, I think the only way to obtain that info is through REST API or SSJS Http Post, isn't it?
    – Javier Gil
    Oct 1, 2020 at 7:41
  • You won’t be able to get this info from API (there are no CP API endpoints) - you can only get those links by checking each CP manually
    – zuzannamj
    Oct 1, 2020 at 7:51
  • Ok, thank you zuzannamj
    – Javier Gil
    Oct 1, 2020 at 9:24

1 Answer 1

0

There is an API method for retrieving Cloudpages using Content Builder API. Unfortunately this does neither show the PublishedURL, nor does it respect Cloudpages built with Classic Editor.

You can use this with POSTMan to check for yourself. The result does NOT contain the publishedURL. It does contain the PageID.

GET {{restEndpoint}}/asset/v1/content/assets?$pagesize=450&$filter=assetType.id=205

Headers

Authorization: Bearer {{accessToken}}
Content-Type: application/json

Params:

$pagesize: 450
$filter: assetType.id=205

Example response (cut off at the end):


{
    "count": 28,
    "page": 1,
    "pageSize": 450,
    "links": {},
    "items": [
        {
            "id": 50652,
            "customerKey": "5c9b0412-a552-4a31-aa4e-xxxxxxx",
            "objectID": "220c172b-d095-4db8-94b5-xxxxxxx",
            "contentType": "text/html",
            "assetType": {
                "id": 205,
                "name": "webpage",
                "displayName": "Web Page"
            },
            "version": 1,
            "name": "test 123",
            "owner": {
                "id": 500019924,
                "email": "xxx@xxx.com",
                "name": "UserNameWhoCreatedThis",
                "userId": "5000xxxxx"
            },
            "createdDate": "2020-03-03T04:29:51.38-06:00",
            "createdBy": {
                "id": xxxxxx,
                "email": "xxx@xxx.com",
                "name": "UserNameWhoCreatedThis",
                "userId": "5000xxxx"
            },
            "modifiedDate": "2020-03-03T04:29:51.38-06:00",
            "modifiedBy": {
                "id": 500019924,
                "email": "x",
                "name": "y,
                "userId": "xxxx"
            },
            "enterpriseId": xxxxxx,
            "memberId": xxxxx,
            "status": {
                "id": 1,
                "name": "Draft"
            },
            "thumbnail": {
                "thumbnailUrl": "/v1/assets/50652/thumbnail"
            },
            "category": {
                "id": xxxx,
                "name": "Content Builder",
                "parentId": 0
            },
            "meta": {
                "globalStyles": {
                    "isLocked": false,
                    "body": {
                        "max-width": "1280px"
                    }
                }
            },
            "views": [...] 


I don't know if you can find the published status, in my test I just found "Draft", but you can try that out with your Business Unit. The above API call only has a filter for assetType.

Using the PageIDs found that way (it should be items.id), you could come up with a rather complicated solution. PageID can be used inside CloudPagesURL() function, normally to create links with encrypted params. We just don't care about the encryption here, we just want the link.

So, if you can find a way to:

  • Get all PageIds in the current BU with the API call seen above (see limitations about classic editor), and maybe write them into a DE.
  • loop through all pageIds in the DE. for each @pageId, render their URL using CloudPagesURL(@pageId)
  • write the result of that into a data extension.

Without the iteration, but for one single cloudpage it would be the following. You can try this in a cloudpage preview.

%%[
set @myURL = CloudpagesURL('1234') /* insert a real PageId from your BU here */
/*InsertData('allCloudpagesDE','url',@myURL)*/ /* create the DE before running this */

/*print the URL: */
]%%%%=v(@myUrl)=%%

With the code above you see one page ID printed. With the loop and insert in place, the result would be, you'd have a Data extension with all URL of non-Classic Cloudpages. As I said, you'd have to check if you can filter for published status.

hope this helps :)

1
  • Thank you Jonas, with my code I can obtain the ID, but it is not the same that the one in Cloud Pages properties interface. Besides, It's not possible use ID to get the url in ssjs. The results of my investigation is: - With url i can get the html inside the CloudPage and from my code or REST API - But, I can't get all the urls of my CloudPages. So, if I want to evaluate all the html in my CloudPages I haver to copypaste the url into a DE and with ssjs obtain the html. Thank you again :)
    – Javier Gil
    Oct 2, 2020 at 10:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .