MS Dynamics动态/以编程方式找到webapi版本在Java代码中,但是无论如何要使其正常运行的步骤会有所帮助

问题描述

我想动态了解我的Web API版本以进行S2S集成设置:

遵循以下文档:

https://docs.microsoft.com/en-us/powerapps/developer/common-data-service/build-web-applications-server-server-s2s-authentication

https://docs.microsoft.com/en-us/powerapps/developer/common-data-service/webapi/discovery-orgsdk-to-webapi

调用globaldiscovery网址以获取版本时获取 401 /未经授权

示例通话: ## query获取发现服务请求的令牌

curl --location --request POST 'https://login.microsoftonline.com/<tenant-id-from-azureAD>/oauth2/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'resource=https://disco.crm.dynamics.com/' \
--data-urlencode 'grant_type=client_credentials' \
--data-urlencode 'client_id=<client-id-from-azure-AD>' \
--data-urlencode 'client_secret=<client-secret>' 

##全局服务请求:

curl --location --request GET 'https://globaldisco.crm.dynamics.com/api/discovery/v1.0/Instances?$select=Version' \
--header 'Accept: application/json; odata.Metadata=minimal' \
--header 'Content-Type: application/json;odata.Metadata=full' \
--header 'OData-MaxVersion: 4.0' \
--header 'OData-Version: 4.0' \
--header 'Authorization: Bearer <access-token-got-from-prev-step>

##以上请求失败,并显示(401未经授权):

{
  "error":{
    "code":"","message":"Authorization has been denied for this request."
  }
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...