Is it possible to call the Increment Column https://developer.salesforce.com/docs/marketing/marketing-cloud/guide/putIncrementColumnValueByKey.html REST API from within a code resource page using SSJS?

It requires the PUT method.

Has anyone done this / maybe have a working example?

Alternatively, is there another way that the column (or entire row, i.e. all columns) can be updated using SSJS (or AMPScript if need be I suppose).



Yes you can, via Script.Util.HttpRequest function. You can see a blog post I made here for details.

Below is a sample of using this script for a PUT call in SSJS:

<script runat=server>
Platform.Load("core", "1.1.1");

var accessToken = {{yourToken}};
var url = 'https://www.exacttargetapis.com/asset/v1/content/assets/{{ContentID}}'

var payload = '{{yourPayload}}';

var auth = 'Bearer ' + accessToken;

  var req = new Script.Util.HttpRequest(url);
  req.emptyContentHandling = 0;
  req.retries = 2;
  req.continueOnError = true;
  req.contentType = "application/json"
  req.setHeader("Authorization", auth);
  req.method = "PUT"; /*** You can change the method here ***/
  req.postData = payload;

  var resp = req.send();

Now there are some other considerations around this that you need to take into account when using it, so I would highly recommend reading the article or otherwise doing further research on this function prior to trying to implement and use it.


Adding to Gortonington's answer, in terms of alternatives for incrementing a number row in a DE from within a code resource,

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