Expand my Community achievements bar.

Announcing the launch of new sub-community for Campaign Web UI to cater specifically to the needs of Campaign Web UI users!
SOLVED

How do I add recipients in the list via API?

Avatar

Level 1

I tried using RegisterGroup function present in the nms:recipient to add a recipient to an existing list. The response is 200 OK but when I look at the adobe campaign console, the list is not updated with the recipient. This is the code that I am using:

<?xml version='1.0' encoding='ISO-8859-1'?>
<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:urn='urn:xtk:session'>
<soapenv:Header/>
<soapenv:Body>
<urn:RegisterGroup>
<urn:sessiontoken>___e3cf1125-82b4-49f4-9083-04bd1945c6d1</urn:sessiontoken>
<entityList><key value="5402862"/>
    <where>
        <condition enabledIf="" expr="@id = 5402862"/>
    </where>
</entityList>
<choiceList><key value="873730"/>
    <where>
        <condition enabledIf="" expr="@id = 873730"/>
    </where>
</choiceList>
<bRegister>true</bRegister>
</urn:RegisterGroup>
</soapenv:Body>
</soapenv:Envelope>

 

This is the response I got from API:

<?xml version='1.0'?>
<SOAP-ENV:Envelope xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:ns='urn:nms:recipient' xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'>
    <SOAP-ENV:Body>
        <RegisterGroupResponse xmlns='urn:nms:recipient' SOAP-ENV:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'></RegisterGroupResponse>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

 

The goal is to add recipients to the list dynamically via API.

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

Hi @AnmolWassan ,

 

If the IDs are correct and you can query the lists and recipients via the API, the issue may be with the bRegister attribute.

The value of this attribute is set to true, which indicates that you want to add the recipient to the list. If you are still unable to add the recipient to the list, you can try using a different web service method to achieve this. For example, you can use the nms:subscriber web service method Subscribe to add a recipient to a list.

Here is an example of the XML request for the Subscribe method:

<?xml version='1.0' encoding='ISO-8859-1'?>
<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:urn='urn:xtk:subscriber'>
<soapenv:Header/>
<soapenv:Body>
<urn:Subscribe>
<urn:sessiontoken>___e3cf1125-82b4-49f4-9083-04bd1945c6d1</urn:sessiontoken>
<urn:subscriberId>873730</urn:subscriberId>
<urn:listId>5402862</urn:listId>
</urn:Subscribe>
</soapenv:Body>
</soapenv:Envelope>

 

In the above example, "subscriberId" is the ID of the recipient you want to add, and listId is the ID of the list to which you want to add the recipient.

View solution in original post

8 Replies

Avatar

Employee Advisor

Hi @AnmolWassan -

The code you posted uses SOAP-based web services to add recipients to a list in Adobe Campaign.

Based on the response you received, it seems that the API call to the RegisterGroup function is successful and returns a 200 OK status code. However, when you check the Adobe Campaign console, the list is not updated with the recipient.

To troubleshoot the issue, I would recommend checking the following things:

  1. Verify that the values passed in entityList and choiceList are correct and correspond to the expected list and recipient.

  2. Check if any errors or exceptions are being thrown in the API call.

  3. Make sure that the API call is being made with the correct user credentials.

  4. Check if the updated list has any restrictions that might prevent the recipient from being added.

Avatar

Level 1

@akshaaga Thanks for your reply. The values in the entityList and choiceList are correct because I am able to query them from the Adobe Campaign console dashboard. I queried the lists via list id (primary key) and recipients via recipient id (primary key). I used both the ids in my code above.Screenshot 2023-02-10 at 2.43.05 PM.png

Screenshot 2023-02-10 at 2.45.09 PM.png

No error is thrown either. It's 200 success response and the API call is made with correct user credentials. The list doesn't have any restrictions as I am able to add the recipient to that list via Adobe Campaign Console.

Is there any other method which I can use to add recipients to the list over API?

Avatar

Correct answer by
Employee Advisor

Hi @AnmolWassan ,

 

If the IDs are correct and you can query the lists and recipients via the API, the issue may be with the bRegister attribute.

The value of this attribute is set to true, which indicates that you want to add the recipient to the list. If you are still unable to add the recipient to the list, you can try using a different web service method to achieve this. For example, you can use the nms:subscriber web service method Subscribe to add a recipient to a list.

Here is an example of the XML request for the Subscribe method:

<?xml version='1.0' encoding='ISO-8859-1'?>
<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:urn='urn:xtk:subscriber'>
<soapenv:Header/>
<soapenv:Body>
<urn:Subscribe>
<urn:sessiontoken>___e3cf1125-82b4-49f4-9083-04bd1945c6d1</urn:sessiontoken>
<urn:subscriberId>873730</urn:subscriberId>
<urn:listId>5402862</urn:listId>
</urn:Subscribe>
</soapenv:Body>
</soapenv:Envelope>

 

In the above example, "subscriberId" is the ID of the recipient you want to add, and listId is the ID of the list to which you want to add the recipient.

Avatar

Level 1

@akshaaga I tried the above method. Used this for reference as well - https://experienceleague.adobe.com/developer/campaign-api/api/sm-subscription-Subscribe.html

but it gave me the following response:

<?xml version='1.0'?>
<SOAP-ENV:Envelope xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'>
    <SOAP-ENV:Body>
        <SOAP-ENV:Fault>
            <faultcode>SOAP-ENV:Error</faultcode>
            <faultstring xsi:type='xsd:string'>SOP-330023 An error occurred during the SOAP call. You don't have the required rights to view the detail.</faultstring>
        </SOAP-ENV:Fault>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

 As per the documentation, the subcribe method works with information services and also accepts a boolean param. Can you confirm if I'm referring to the correct subcribe method and the code is correct?

Avatar

Employee Advisor

@AnmolWassan ,

The error message "SOP-330023 An error occurred during the SOAP call. You don't have the required rights to view the detail." suggests that the user credentials you're using to make the API call don't have sufficient rights to operate.

Regarding the subscribe method, it is correct to use it with information services, but note that you need to have the correct information service endpoint URL, and that the subscribe method only works with certain types of information services. Additionally, the boolean parameter "subscribe" that you pass as an argument should be set to "true" to add the recipient to the list.

Avatar

Level 1

@akshaaga I'm not sure I quite understand. I don't want to link the recipient to any information service, hence I don't think subscribe method will help me achieve my goal.

As per the documentation, I find these methods applicable for me:

https://experienceleague.adobe.com/developer/campaign-api/api/sm-group-Register.html?hl=register

https://experienceleague.adobe.com/developer/campaign-api/api/sm-recipient-RegisterGroup.html?hl=reg...

I also tried using rcpGrpRel with the below code but it is giving me error:

<?xml version='1.0' encoding='ISO-8859-1'?>
<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:urn='urn:xtk:session'>
    <soapenv:Header/>
    <soapenv:Body>
        <urn:Write>
            <urn:sessiontoken>___81905981-fa3d-4d0a-986e-f5f077c19d21</urn:sessiontoken>
            <urn:domDoc>
                <recipient _key="@id" id="869526" xtkschema="nms:recipient">
                    <rcpGrpRel _key="[rcpGroup/@id]">
                        <rcpGroup id="5403042"/>
                    </rcpGrpRel>
                </recipient>
            </urn:domDoc>
        </urn:Write>
    </soapenv:Body>
</soapenv:Envelope>

I am okay if either of the methods help me achieve the goal of adding a recipient to the list.

Avatar

Employee Advisor

Hi @AnmolWassan ,

 

The code you posted for the rcpGrpRel method seems correct, except for one thing.

You need to provide a value for the _operation attribute. The _operation attribute indicates the type of update you want to perform on the recipient. In this case, you want to add the recipient to the group, so you can set the value of _operation to "insert".

Here is an updated version of the code:

<?xml version='1.0' encoding='ISO-8859-1'?>
<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:urn='urn:xtk:session'>
<soapenv:Header/>
<soapenv:Body>
<urn:Write>
<urn:sessiontoken>___81905981-fa3d-4d0a-986e-f5f077c19d21</urn:sessiontoken>
<urn:domDoc>
<recipient _key="@id" id="869526" xtkschema="nms:recipient">
<rcpGrpRel _operation="insert" _key="[rcpGroup/@id]">
<rcpGroup id="5403042"/>
</rcpGrpRel>
</recipient>
</urn:domDoc>
</urn:Write>
</soapenv:Body>
</soapenv:Envelope>

 

You can make a similar change to the register and registerGroup methods.

Avatar

Administrator

Hi @AnmolWassan,

Were you able to resolve this query with the help of @akshaaga's suggestions or do you still need more help here? Do let us know. In case the given suggestions were helpful, then kindly choose the one that helped you the most as the 'Correct Reply'.
Thanks!



Sukrity Wadhwa