1

I'm having some issue with something I'm trying to do using SOAP, What I want is to add a Task to an existing automation, the documentation shows how to update the name but nothing else. I want to add an SQL Query to the automation, and I can't find anyone that did that, is it possible ?

I have the same issue as this Q&A: Update Marketing Cloud Automation tasks with SOAP API returns "OK" response but doens't update

1 Answer 1

0

I honestly would recommend doing REST API (even though it is undocumented) instead of SOAP. I find it much easier to interact with in comparison to the SOAP API.

Create an Automation REST API:

POST /automation/v1/automations/
Host: {{tse}}.rest.marketingcloudapis.com
Authorization: Bearer {{authToken}}
Content-Type: application/json

{
    "name": "myAutoName",
    "description": "created via REST",
    "key": "myAutoKey",
    "typeId": 1,
    "type": "scheduled",
    "steps": [
        {
            "stepNumber": 0,
            "activities": [
                {
                    "name": "myActivity",
                    "activityObjectId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx",
                    "objectTypeId": 423,
                    "displayOrder": 0
                }
            ]
        },
        {
            "stepNumber": 1,
            "activities": [
                {
                    "name": "myActivity2",
                    "activityObjectId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx",
                    "objectTypeId": 423,
                    "displayOrder": 0
                }
            ]
        }
    ],
    "startSource": {
        "typeId": 1,
        "schedule": {
            "scheduleTypeId": 2,
            "startDate": "2222-05-13T16:00:00",
            "endDate": "2444-05-13T16:00:00",
            "rangeTypeId": 0,
            "occurrences": 1,
            "icalRecur": "FREQ=HOURLY;COUNT=1;INTERVAL=1",
            "timezoneId": 5,
            "statusId": 0
        }
    }
}

For each activity you only need either name or ObjectID along with objectTypeId. I showed all in my example to give a more robust view into it.

Edit an Automation REST API:

PATCH /automation/v1/automations/{{autoID}}
Host: {{tse}}.rest.marketingcloudapis.com
Authorization: Bearer {{authToken}}
Content-Type: application/json

{
    "steps": [
        {
            "annotation": "",
            "stepNumber": 0,
            "activities": [
                {
                    "name": "myActivity",
                    "activityObjectId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx",
                    "objectTypeId": 423
                }
            ]
        },
        {
            "annotation": "",
            "stepNumber": 1,
            "activities": [
                {
                    "name": "myActivity2",
                    "activityObjectId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx",
                    "objectTypeId": 423
                }
            ]
        }
    ]
}

For editing, you only need to include the information you want to change, as the Auto ID inside the url will attach it to the correct object. This follows same rules as create otherwise in regards to identifying activities.

For a list of ObjectTypeIDs, you can go here.

3
  • Thanks for your help, I will dig into your answer and will let you know if it worked for me !
    – Sercan
    Feb 13, 2023 at 7:34
  • This is exactly what I needed, thanks for your help ! Can I ask you how you managed to find that without a proper documentation ?
    – Sercan
    Feb 13, 2023 at 8:17
  • Digging in the UI for REST API endpoints and then digging through those to find any public facing ones I could. Then just a ton of trial and error to figure out the rest. Feb 13, 2023 at 19:20

You must log in to answer this question.

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