Development, Howto

How to Add records to Marketing List using WebApi

Following code can be used to add records to Marketing List using JavaScript and WebApi:



  1. Hi Andrew,

    Samething we are doing and code also same but we are facing an issue while 3000 members adding . getting error like ‘ Failed to insert audit record” . Please answer if you have any idea about this. It will help us.

    1. Kirna,
      To be honest I have no idea about that error, never seen that error before.

  2. Hi Andrew, and others,

    If you are trying to add marketing list members through the webAPI and you’re faced with the error message “Specified cast is not valid.”, then make sure that you’re adding contacts to a list that is targeted at contacts, and not inadvertedly mix contacts, accounts and leads to lists that aren’t targeted at that entity type.


  3. How create a new Marketinglist?

    I try’d a POST to list ({{webapiurl}}lists) with following body
    “listname”:”TEST MB 120122 List”,
    “purpose”: “Test with leads”,
    “source”: “leads”,
    “cost”: 10000

    but I got an error from the endpoint:
    “error”: {
    “code”: “0x80040265”,
    “message”: “Object reference not set to an instance of an object.”

    1. Susan, you should add createdfromcode field to your request that should have one of values – 1 if the target list is for accounts, 2 – for contacts and 4 for leads. Andrew

      1. Hi Andrew – Can this still be done? I can’t seem to find AddListMembersList with v9.0

        1. Ryan,
          Yes, that should work fine. I checked Dataverse Rest Builder and it provides the code so I would assume it should work.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.