Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Contact created using API

(0) ShareShare
ReportReport
Posted on by

I created a contact in Dynamics 365 by using SOAP Api. Is there a flag or audit stamp in dynamics which would confirm that the contact was created/modified by API?

Thanks, 

Manik Soi

*This post is locked for comments

  • Suggested answer
    NicksTuk Profile Picture
    1,833 on at
    RE: Contact created using API

    You could either use a specific account only for records created through API, or you could put a custom flag on the record and raise it for records created in that manner, if you need to track that.

  • Suggested answer
    Aric Levin - MVP Profile Picture
    30,188 Moderator on at
    RE: Contact created using API

    Hi,

    If you are using WebApi, the following should be your code to create a Contact record:

    var entity = {};

    entity.firstname = "John";

    entity.lastname = "Smith";

    entity.emailaddress1 = "john.smith@contoso.com";

    entity.new_createdfromwebapi = 1;

    var req = new XMLHttpRequest();

    req.open("POST", Xrm.Page.context.getClientUrl() + "/api/data/v8.2/contacts", true);

    req.setRequestHeader("OData-MaxVersion", "4.0");

    req.setRequestHeader("OData-Version", "4.0");

    req.setRequestHeader("Accept", "application/json");

    req.setRequestHeader("Content-Type", "application/json; charset=utf-8");

    req.onreadystatechange = function() {

       if (this.readyState === 4) {

           req.onreadystatechange = null;

           if (this.status === 204) {

               var uri = this.getResponseHeader("OData-EntityId");

               var regExp = /\(([^)]+)\)/;

               var matches = regExp.exec(uri);

               var newEntityId = matches[1];

           } else {

               Xrm.Utility.alertDialog(this.statusText);

           }

       }

    };

    req.send(JSON.stringify(entity));

    The newEntityId will return the newly created contact Id value from your request. If there is a value there, you know contact is created.

    You can add a field to your contact entity called Created from Api, which you pass to your contact form that will specify when this was created from the Web Api. You can probably use one of the existing fields on the contact entity for this as well.

    Hope this helps.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Leaderboard > Microsoft Dynamics CRM (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 83 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 54

#3
Victor Onyebuchi Profile Picture

Victor Onyebuchi 6

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans