Hi
So I'm developing an application and I need to connect to Dataverse in order to retrieve data from custom tables. I'm able to get an access token, but when using the token in following requests I always get 401. Steps I have followed so far:
From my code I can successfully get an access token. I then include it in a Postman request as Authorization header, and perform a GET https://<org>.api.crm4.dynamics.com/api/data/v9.2/contacts. It always returns 401 - Unauthorized.
I'm developing the app in NodeJS and can't find documentation about it, so any help or guidance would be much appreciated.
Thanks in advance!
Regards,
Hey All,
I thought of starting a new thread but my issue is similar to this. I was hoping I'd just piggy back on this.
I have an issue with getting data back from Dataverse using the Web API. I can connect to the endpoint and get a 200/OK http status. But there is no data returned by the searchquery API.
Any thoughts?
Here's a little more background:
I have enabled search in my environment, added a few tables to be indexed via my PowerAutomate solution, then added columns to be indexed using the 'Quick Find' views of my custom tables.
I can successfully use the global search within my model-driven power app. I can also search using the 'Search rows (preview)' dataverse action in Power Automate. So it seems that I have a perfectly functioning search index. So why isn't the API returning any data?
Here is the request/response from an "Invoke Http Request with Entra ID" action in Power Automate:
URI: https://MYENV.crm.dynamics.com
API: /api/data/v9.2/searchquery
Request body: { "top": 10, "count": "true",
"search": "My keyword here"
}
Response:
"body": {
"@odata.context": "https://MYENV.crm.dynamics.com/api/data/v9.2/$metadata#Microsoft.Dynamics.CRM.searchqueryResponse",
"response": "{\"Error\":null,\"Value\":[],\"Facets\":{},\"QueryContext\":null,\"Count\":0}"
}
Thanks in advance.
Hi,
Thanks for replying, I have trouble connecting to the correct Environment while update the data verse table through, Can we please connect over call ?
Please Provide the contact details for Connecting.
Hi
When accessing my Dynamics instance, the URL looks like the following:
I don't know why, but sometimes it gives you 4, I have also seen some of them given with 8... I'm not the one deploying Dynamics so maybe it has something to do with the way to do so..
Regards,
Hi ,
Can you Please let me know, why you kept 4 in the URL.
Understood, that is how it will work once you get the access token properly and query Dataverse, user interaction will not be needed as you will be passing in your App Registration client id and secret. You can even use CBA if you wanted to avoid the secret.
You will want to try to get the Authentication piece/access token working in Postman, perhaps you are missing a configuration in the App Registration to allow it to work - i've followed that article in the past and connected successfully to execute the whoami request. Take a look at the article below to ensure you've done all the steps in your AppReg.
https://www.matthewdevaney.com/a-visual-guide-to-power-platform-service-principal-setup/
I can also share with you a power automate http connector configuration I have for connecting to GraphAPI - its very similar to yours to connect via OAuth.
Hi all
So the problem was the URL. I was using ["https://<org>.crm.dynamics.com/.default"], but instead it was ["https://<org>.crm4.dynamics.com/.default"]. I was missing the '4'. I'm now able to retrieve data from Dataverse successfully.
Kind regards
Hi
Thanks for answering.
I'm afraid it's not working. When I select Get Access Token, a window pops asking for user and password. I introduce my credentials and get this:
Nevertheless, even if it worked, my goal is to connect from my express server developed in NodeJS, so the authentication should be done by using the access token so the server can retrieve data without user interaction.
In case it's helpful, I'm using the @Anonymous/msal library to get the access token, and configured it as it follows:
Take a look at this article - it should walk you through how to set up your postman environment to connect to dataverse and send requests for testing. It seems like you've properly set up the App Reg for the environment so just follow the remaining steps.