web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Suggested Answer

Problem connecting with Dynamics Web Api - Involuntary change URL

(0) ShareShare
ReportReport
Posted on by

Hello:

I'm having a trouble accesing to Dynamics 365 web Api with NodeJs.

I'm using this function to operate:

var dynamicsWebApi = new DynamicsWebApi({
       webApiUrl: [URL],
       onTokenRefresh: [MY_TOKEN]

});

The problem, the adress I use is:

desgrupohiberus.crm4.dynamics.com/api/data/v9.1

But, after call the method "retrieveMultipleRequest" I have a 403 and the adress is

desgrupohiberus.api.crm.dynamics.com

This adress not exists and I don't know why this chage, it's involuntary.

Any ideas?

Kind regards

I have the same question (0)
  • meelamri Profile Picture
    13,218 User Group Leader on at

    Hello,

    Can you share your code ?

  • Community Member Profile Picture
    on at

    It's a custom integration:
    --------------------------------------

    exports.handler = function(context, event, callback) {

       var numTelefono = event.num;

       var DynamicsWebApi = require('dynamics-web-api');

       var resource = 'https://'+context.THE_ORG+'.crm4.dynamics.com';

       var destino = 'https://'+context.THE_ORG+'.crm4.dynamics.com/api/data/v9.1/';

      function acquireToken(dynamicsWebApiCallback){

          dynamicsWebApiCallback(event.token);

      }  

      //create DynamicsWebApi object

      var dynamicsWebApi = new DynamicsWebApi({

          webApiUrl: destino,

          onTokenRefresh: acquireToken

      });

      var request = {

          collection: "contacts",

          select: ["fullname", "firstname","lastname","emailaddress1","contactid","mobilephone"],

          filter: "mobilephone eq '"+ numTelefono+"'",

          maxPageSize: 5,

          count: true

      };

      //perform a multiple records retrieve operation

      dynamicsWebApi.retrieveMultipleRequest(request).then(function (response) {

          var count = response.oDataCount;

          var nextLink = response.oDataNextLink;

          var records = response.value;

          var recordCount = Object.keys(records).length;

          if (recordCount >=1){

              console.log(records[0].contactid);

              console.log(records[0].firstname);

              console.log(records[0].incidentID);

              var incidentID;

              var caseNumber;

              //Get incidentID

              var caseContact='contact('+records[0].contactid+')';

              console.log(caseContact);

              request = {

                  collection: "incidents",

                  select: ["ticketnumber,incidentid"],

                  filter: "_customerid_value eq "+records[0].contactid,

                  maxPageSize: 1,

                  count: true

              };

              //perform a multiple records retrieve operation

              dynamicsWebApi.retrieveMultipleRequest(request).then(function (response) {

                  var caseRecords = response.value;

                  var caseRecordCount = Object.keys(caseRecords).length;

                  if (caseRecordCount >=1){

                      incidentID = caseRecords[0].incidentid;

                      caseNumber= caseRecords[0].ticketnumber.substr(4);

                      console.log(caseNumber);

                      console.log('Found case');

                      //callback(null,{ticketNumber: caseRecords[0].ticketnumber, incidentid:caseRecords[0].incidentid} );

                      callback(null, {

                          contact_id: records[0].contactid,

                          first_name: records[0].firstname,

                          email: records[0].emailaddress1,

                          last_name: records[0].lastname,

                          phone: records[0].mobilephone,

                          CaseNumber: caseNumber,

                          incidentID: incidentID

                      });

                  }

                  else{

                      console.log('No case');

                      callback(null, {

                          contact_id: records[0].contactid,

                          first_name: records[0].firstname,

                          email: records[0].emailaddress1,

                          last_name: records[0].lastname,

                          phone: records[0].mobilephone,

                          CaseNumber: caseNumber,

                          incidentID: incidentID

                      });

                  }

              })

              .catch(function (error){

                  //catch an error

                  console.log(error);

                   console.log('Error no record 2');

                  callback(null,error);

              });

          }

          else{

              console.log('Error no record 1');

              callback(null,'Error');

          }

      })

      .catch(function (error){

          //catch an error

          console.log(error);

           console.log('Error no record at all');

          callback(null,'No Record');

      });

    };

  • Community Member Profile Picture
    on at

    ____

  • meelamri Profile Picture
    13,218 User Group Leader on at

    are you using adal to aquire your token ?

  • Community Member Profile Picture
    on at

    Yes, I use Adal

  • meelamri Profile Picture
    13,218 User Group Leader on at

    What do you get when you perform WhoAmI function:

    dynamicsWebApi.executeUnboundFunction("WhoAmI").then(function (response) {

       console.log('Hello Dynamics 365! My id is: ' + response.UserId);

    }).catch(function(error){

       console.log(error.message);

    });

  • Community Member Profile Picture
    on at

    In this case of (WhoAmI):

    ------------------

    message: 'The user is not a member of the organization.',

    status: 403,

    statusMessage: 'Forbidden'


    In case of (retrieveMultipleRequest):
    --------------------------

    Error: getaddrinfo ENOTFOUND desgrupohiberus.api.crm.dynamics.com

    errno: 'ENOTFOUND',

     code: 'ENOTFOUND',

     syscall: 'getaddrinfo',

     hostname: 'desgrupohiberus.api.crm.dynamics.com',

     host: 'desgrupohiberus.api.crm.dynamics.com',

     port: 443

    I asume, the URL is changing somehow

  • Suggested answer
    meelamri Profile Picture
    13,218 User Group Leader on at

    Hi,

    I'm not sure if it's related to URL issue. I recommend reviewing your registered application in Azure Active Directory. 

  • Community Member Profile Picture
    on at

    I can't understad the problem

    Complete info of error:

    code: '0x80072560',

     message: 'The user is not a member of the organization.',

     status: 403,

     statusMessage: 'Forbidden'

    But, i'm creating the token without problem

  • meelamri Profile Picture
    13,218 User Group Leader on at

    Did you create an application user in your CRM ?

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
Pallavi Phade Profile Picture

Pallavi Phade 102 Super User 2026 Season 1

#2
ManoVerse Profile Picture

ManoVerse 58 Super User 2026 Season 1

#3
Abhilash Warrier Profile Picture

Abhilash Warrier 55 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans