I was reading the documentation and stuck in a problem that I do not know how to get Dynamics resource
for acquiring access_token
using any API (I know my CRM root service address but I do not want to hard-code this service name in my code base). Could you please provide me with the solution to this problem?
Asked
Active
Viewed 294 times
0

Arun Vinoth-Precog Tech - MVP
- 22,364
- 14
- 59
- 168

Pavlo Mykhailyshyn
- 203
- 1
- 6
- 20
-
`string resource = "https://mydomain.crm.dynamics.com"` mydomain is the name of your organization... do you want to get this info dynamically ? – Alex Feb 27 '19 at 14:48
-
Yes, exactly! But I need to fetch this info using any possible REST request. – Pavlo Mykhailyshyn Feb 28 '19 at 07:59
2 Answers
0
You need not to hard code it in code base like showed in documentation sample. But normally we will keep this in web.config
or app.config
xml file just like any connection string & consume it.
Use connection strings in XRM tooling to connect to Common Data Service for Apps

Arun Vinoth-Precog Tech - MVP
- 22,364
- 14
- 59
- 168
-
Sorry that I did not mention that I`m looking for REST request to get info about my service name. Can it be also done by using any request to the endpoint? For now I`m using such an API "/api/data/v9.0", but it requires 'access_token' to do that and to acquire 'access_token' you need resource, so how can I retrieve it(resource = service name)? – Pavlo Mykhailyshyn Feb 27 '19 at 09:41
-
@PavloMykhailyshyn I feel like you cannot circumvent that scenario.. in other words chasing the own tail.. I remember the old days of on premise CRM with multi tenants concept - we will do a discovery service call to pull all the orgs & iterate them. you are looking for something like that. – Arun Vinoth-Precog Tech - MVP Feb 27 '19 at 14:48
0
You can use the Online Management API to get a list of all the Dynamics 365 instances in your Office 365 tenant. I believe this is what the Plugin Registration tool does when you check "Display a list of the Organization(s)".
This looks useful:
The C# sample demonstrates how to authenticate to the Online Management API and then retrieve all Customer Engagement instances from your Office 365 tenant.
-
Which token type should I use to retrieve the information from the request to GET `https://admin.services.crm4.dynamics.com/api/v1.1/instances` – Pavlo Mykhailyshyn Feb 28 '19 at 08:38