Skip to main content
Group

API Token Changes

Beginning October 25, 2016, accessing your Marketing Cloud account by passing API access tokens in the URL will no longer be supported. Please post any questions regarding this change.

I created a link through a developers sandbox where i imported data. I created code for external app that went through aksing for username and password and then ran the query through PHP Curl and passing back through JS AJAX. Everything worked... i came back and not having changed anything, it stopped working. Is there a time limit on the token,etc. Having tried several things, refreshing the consumer key and secret, i even created a new connected App and changed the key and secret. It still doesn't work. 

 

I get "ParseOPdata.js:9 Error: Authentication error." Does anyone have any idea what it could be?

0/9000

This is the code and the way i tested is the print is not shown in the debug , is it because i have to add any access token ? I have added the endpoint in the remote settings

@future(callout=true)

private static void postCallout(String orderPayload){

Http http = new Http();

HttpRequest request = new HttpRequest();

request.setEndpoint('https://mcqm4hcy220xj6f5d1ypdf-zlrz4.auth.marketingcloudapis.com/v2/token');

request.setMethod('POST');

request.setHeader('Content-Type', 'application/json');

request.setBody(orderPayload);

HttpResponse response = http.send(request);

System.debug('response: ' + response);

if(response.getStatusCode() == 200){

// TODO: update some field on Supply records

System.debug('Order POST Callout Success');

}

}

2 answers
  1. Nov 21, 2022, 3:30 PM

    @Trevor Krieg thanku <3, i have one more doubt I wrote contactkey and eventdefinition as string request body , can i do the same for Data and its subcategory ? how can we write data,guid and bodycontent as they look like they are subcategory,pls help

    String RequestBody ='ContactKey=blah';

    RequestBody +='&EventDefinitionKey=blah;

    "ContactKey": "blah",

    "EventDefinitionKey": "blah",

    "Data": {

    "GUID": "000",

    "BodyContent":"",

    }

0/9000

I need this apex trigger for orders But it has to be triggered when account field status changes.How can i choose the acc status not null and then the order should be triggered for sending as a callout

trigger OrderTrigger1 on Order (before insert) {

switch on Trigger.operationType {

when BEFORE_UPDATE {

OrderTriggerHandler.beforeUpdate(Trigger.oldMap, Trigger.new);

}

}

}

12 answers
  1. Ruchit Patel (Cognizant) Forum Ambassador
    Nov 19, 2022, 2:06 PM

    @46Fathima hussain cs1 please try this

     

    Trigger

    trigger OrderTrigger1 on Order (before insert, after update) {

    switch on Trigger.operationType {

    when BEFORE_UPDATE {

    OrderTriggerHandler.beforeUpdate(Trigger.oldMap, Trigger.new);

    }

    when AFTER_UPDATE {

    OrderTriggerHandler.afterUpdate(Trigger.oldMap, Trigger.new);

    }

    }

    }

    Handler

    public with sharing class OrderTriggerHandler {

    public static void beforeUpdate(Map<Id, Order> oldOrderMap, List<Order> newOrderList){

    OrderCallouts.sendOrderToJSONServer(oldOrderMap, newOrderList);

    }

    public static void afterUpdate(Map<Id,Order> oldMap, List<Order> newList) {

    List<Order> newOrders = new List<Order>();

    for(Order o : newList) {

    if(o.AccountId != null && o.Account.Status__c != null) {

    newOrders.add(o);

    }

    }

    if(!newOrders.isEmpty()) {

    // callout

    }

    }

    }

0/9000
0/9000