5

Has anyone found a way to get a CloudPage URL via the API? I can get the asset collection as listed here,

https://developer.salesforce.com/docs/atlas.en-us.noversion.mc-apis.meta/mc-apis/content-api.htm

but no where in the returned data can I find the cloudpage URL or even a portion of the url, so that I could construct the full URL myself.

EDIT: I should mention that when I say via API, I'm not referring to AMPScript or SSJS. Ideally, I Need to be able to get this without accessing the SFMC UI.

I suppose if SSJS can do it I can first create the SSJS, create and invoke an automation which can maybe populate it to a newly created DE that I can read, but that seems a bit like overkill.

1
  • 2
    I don't believe this is possible using the API. I've tested several ways around it without success. SFMC use an internal endpoint to get this kind of data: /internal/v1/cloudpages. Jan 28 '20 at 13:15
4

I've found a way to do this - however it could be a security vulnerability.

The CloudPagesURL() function requires a SubscriberKey value to render; since it's generation a QueryString (qs) value for that specific subscriber. There is a feature/bug that you can exploit to create your own micro endpoint to render these Subscriber-Specific links.

Below is how to solve your use case:

  1. Create a JSON "Code Resource" in Cloud Pages
  2. Put the following code in the JSON Cloud Page: %%=CloudPagesURL(xxxx)=%%

  3. Save & Publish the Cloud Page

  4. Click on the URL Link provided when you publish the page. Edit the URL and add ?sk=#SubscriberKey# (where "#SubscriberKey#" is the SubscriberKey you are rendering the cloud page for) to the end of the URL. The final URL should look something like this:

https://cloudpage.exacttarget.example.com/myCloudPageName?sk=Tester_1234567

The content of the page will be full URL target of your CloudPagesURL() function, including the subscriber-specific "qs" value at the end.

You can convert this into a JSON-compliant response by adding some structure to the response. For example:

{"SubscriberPage":"%%=CloudPagesURL(xxxx)=%%"}

With the above structure you can use a HTTPGET request (remember to include gzip headers) to return this JSON payload for your use outside of the platform.

Again, use this at your own risk - it's effectively a back door to impersonate any subscriber's view of a CloudPage "as if they had clicked a link from an email".

1
  • thanks for the answer. It's not quite what I'm looking for as I'm trying to do this without using the UI. I could potentially be in hundreds of accounts and won't have the option to follow the workflow you described, but it is a great suggestion
    – garek007
    Jan 28 '20 at 19:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.