0

I'm trying to retrieve the CustomObjectID of a data extension that already exists, by using the External Key/CustomerKey. That didn't work, so now I'm trying to retrieve any DEs at all, and that's not working either. Here is my code, I'm running it in a Landing page:

<script runat="server">
Platform.Load("Core","1");
var clientID = Attribute.GetValue('memberid');

var api = new Script.Util.WSProxy();
api.setClientId({"ID": clientID});
var cols = [ "Name", "CustomerKey", "CategoryID", "IsSendable"];
var res = api.retrieve("DataExtension",cols);
Write(res);

</script>

I don't get a JSON object back. What is written out is:

System.Collections.Generic.Dictionary`2[System.String, System.Object] 

I don't know what this means, except that there are no data extension objects to return? I'm literally following the exact example in the documentation:-

https://developer.salesforce.com/docs/atlas.en-us.mc-programmatic-content.meta/mc-programmatic-content/ssjs_WSProxy_basic_retrieve.htm

I can't even get the describe function to work:

var res = api.describe("DataExtension");

returns the same result -

System.Collections.Generic.Dictionary`2[System.String,System.Object] 

To add to the confusion, I can use describe and retrieve QueryDefinition objects and emailSendDefinition objects just fine - no issue there.

2 Answers 2

2

Change the last line to:

Write(Stringify(res));

Stringify will display the res variable that contains the response as JSON key and values with double quotes.

4
  • This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From Review
    – David Reed
    Commented Sep 1, 2018 at 13:52
  • A bit harsh @DavidReed ?
    – 0xsegfault
    Commented Sep 2, 2018 at 10:35
  • 2
    @data_kid This answer was edited after I saw it in Review. At the time, it was a comment that did not provide an answer, but has been improved.
    – David Reed
    Commented Sep 2, 2018 at 10:38
  • Stringify() does not work - it need an object. Since I'm not getting a JSON object back as a response, I just get an error that Stringify() is expecting an object.
    – imeisner
    Commented Sep 3, 2018 at 21:53
0

turns out the issue was with the Stringify function. I did not notice it at the time, but I had a lowercase 's' in my code:

Write(stringify(res));

When I should have had

Write(Stringify(res));

And now everything actually works. The code block where I was using describe for QueryDefinition and EmailSendDefinition had the correct capitalized Stringify().

Lesson learned: starting a new code project on Friday afternoon before a holiday weekend is just not a good idea.

You must log in to answer this question.

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