Search code examples
phpdynamics-crmversioning

Dynamics CRM API not available


Can't seem to find an answer to this error anywhere, here's what I'm trying to do.

I'm using postman to test the API before writing code (PHP), when I do a request to to the CRM api endpoint https://orgname.crm.dynamics.com/api/data/v8.2/accounts I keep getting the following error:

{
  "error": {
    "code": "",
    "message": "Requested API Version 'v8.2' is not available",
    "innererror": {
      "message": "Requested API Version 'v8.2' is not available",
      "type": "Microsoft.Crm.CrmHttpException",
      "stacktrace": "   at Microsoft.Crm.Extensibility.OData.CrmODataRoutingConvention.ValidateApiVersion(Version version, IOrganizationContext context, String versionStr)\r\n   at Microsoft.Crm.Extensibility.OData.CrmODataRoutingConvention.SelectController(ODataPath odataPath, HttpRequestMessage request)"
    }
  }
}

Any idea?

Here's the postman request

Auth:

POST /64aa16ab-5980-47d5-a944-3f8cc9bbdfa2/oauth2/token HTTP/1.1
Host: login.windows.net
Content-Type: application/x-www-form-urlencoded
Cache-Control: no-cache

grant_type=password&client_secret=<<secret>>&client_id=<<id>>&resource=https%3A%2F%2F<<orgname>>.crm.dynamics.com%2F&username=<<user>>&password=<<password>>

Endpoint:

GET /api/data/v8.2/accounts HTTP/1.1
Host: <<orgname>>.crm.dynamics.com
Accept: application/json
OData-MaxVersion: 4.0
OData-Version: 4.0
Authorization: Bearer <<token>>
Cache-Control: no-cache

A related issue I found, thinking that the version I was using was deprecated: microsoft crm 2016 api version auto-discovery

Thanks for the help!


Solution

  • It seems I was using the wrong URL,

    Here's the url I should have been using https://<<orgname>>.api.crm.dynamics.com/api/data/v8.1/

    And here's where to find it: Go into Settings > Customization > Customizations > Developer Resources. Your url is the one next to Service Root URL