• RAJESH KARKI 6
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 1
    Replies
I am using Apex (in Service Cloud) to call Marketing Cloud Data Extension to delete some record by email address. Below is my code. For some reason, I am getting System.HttpResponse[Status=Bad Request, StatusCode=400] error. I could not tell what is wrong with my request.. I also tried using SoapUI to test my call and I get bad request error there as well. Below is my method. Guidance appreciated.

public void SoapEnvCall()
{
  String soapTemplate =
    '<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">'+
    ' <Header>'+
    '<Security xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">'+
    '<UsernameToken>'+
    '<Username>my marketing cloud username</Username>'+
    '     <Password>my marketing cloud password</Password>'+
    '   </UsernameToken>'+
    ' </Security>'+
    '  </Header>'+
    ' <Body>'+
    '    <DeleteRequest xmlns="http://exacttarget.com/wsdl/partnerAPI">'+
    '       <Options/>'+
    '      <Objects xsi:type="DataExtensionObject">'+
    '         <PartnerKey xsi:nil="true"/>'+
    '         <ObjectID xsi:nil="true"/>'+
    '        <CustomerKey>my dataextension external key</CustomerKey>'+
    '      <Keys>'+
    '         <Key>'+
    '            <Name>Email_Address</Name>'+
    '           <Value>bobTest@intouchsol.com</Value>'+
    '      </Key>'+
    '    </Keys>'+
    ' </Objects>'+
    ' </DeleteRequest>'+
    ' </Body>'+
    ' </Envelope>';

    System.debug('#######################soapTemplate: '+ soapTemplate);
      
    Http h = new Http();
    HttpRequest req = new HttpRequest();
    req.setMethod('POST');
    req.setHeader('SOAPAction','Delete');
    req.setHeader('Accept-Encoding','gzip,deflate');
    req.setHeader('Content-Type','text/xml;charset=UTF-8');
    req.setHeader('User-Agent','Jakarta Commons-HttpClient/3.1');
    req.setBody(soapTemplate);
    req.setEndpoint('https://webservice.s7.exacttarget.com/Service.asmx');
    string bodyRes = '';         
    try {
        HttpResponse res = h.send(req);
        bodyRes = res.getBody();
        } 
        catch(System.CalloutException e) {
        System.debug('Callout error: '+ e);
        ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.FATAL, e.getMessage()));
        }               
    System.debug('Soapponse:' + bodyRes);
I am currently working on Beginner Developer Trailhead: Data Security: Define Sharing Rules - "Define a Public Group" section. I am stuctk at item no. 5 below. In the Available Members list, I DONT SEE SW Dev Manager, Director Product Management, or Director QA. Any direction is appreciated. Also, I don't see Recruiting Manger (item 7).

1. From Setup, enter Public Groups in the Quick Find box, then select Public Groups.
2. Click New.
The New Public Group page allows you to choose other public groups, individual roles, individual roles including the roles' subordinates, or individual users.
3. In the Label text box, enter Reviewers. Click in the Group Name text box to populate it automatically. Group Namerefers to the unique name used by the API and managed packages.
4. In the Search drop-down list, choose Roles.
5. In the Available Members list, select SW Dev Manager, Director Product Management, and Director QA, then clickAdd.
6. Go back up to the Search drop-down list, and this time choose Role and Subordinates.
7. In the Available Members list, select Recruiting Manager, and click Add.
8. Click Save.
I am currently working on Beginner Developer Trailhead: Data Security: Define Sharing Rules - "Define a Public Group" section. I am stuctk at item no. 5 below. In the Available Members list, I DONT SEE SW Dev Manager, Director Product Management, or Director QA. Any direction is appreciated. Also, I don't see Recruiting Manger (item 7).

1. From Setup, enter Public Groups in the Quick Find box, then select Public Groups.
2. Click New.
The New Public Group page allows you to choose other public groups, individual roles, individual roles including the roles' subordinates, or individual users.
3. In the Label text box, enter Reviewers. Click in the Group Name text box to populate it automatically. Group Namerefers to the unique name used by the API and managed packages.
4. In the Search drop-down list, choose Roles.
5. In the Available Members list, select SW Dev Manager, Director Product Management, and Director QA, then clickAdd.
6. Go back up to the Search drop-down list, and this time choose Role and Subordinates.
7. In the Available Members list, select Recruiting Manager, and click Add.
8. Click Save.
I am currently working on Beginner Developer Trailhead: Data Security: Define Sharing Rules - "Define a Public Group" section. I am stuctk at item no. 5 below. In the Available Members list, I DONT SEE SW Dev Manager, Director Product Management, or Director QA. Any direction is appreciated. Also, I don't see Recruiting Manger (item 7).

1. From Setup, enter Public Groups in the Quick Find box, then select Public Groups.
2. Click New.
The New Public Group page allows you to choose other public groups, individual roles, individual roles including the roles' subordinates, or individual users.
3. In the Label text box, enter Reviewers. Click in the Group Name text box to populate it automatically. Group Namerefers to the unique name used by the API and managed packages.
4. In the Search drop-down list, choose Roles.
5. In the Available Members list, select SW Dev Manager, Director Product Management, and Director QA, then clickAdd.
6. Go back up to the Search drop-down list, and this time choose Role and Subordinates.
7. In the Available Members list, select Recruiting Manager, and click Add.
8. Click Save.