【问题标题】:Problems assigning licenses with microsoft graph使用 microsoft graph 分配许可证的问题
【发布时间】:2017-06-19 16:04:21
【问题描述】:

我的代码如下所示

https://developer.microsoft.com/en-us/graph/docs/api-reference/beta/api/user_assignlicense

$datos=array("addLicenses"=>array(array("skuId"=>$sku)));
$this->graph->setApiVersion("beta");
$this->crear("users/$id_user/assignLicense", $datos);

public function crear($objeto, $datos){ 
    $r = $this->graph->createRequest("POST", "/$objeto")
        ->attachBody($datos)            
        ->execute();
} 

错误

Type: GuzzleHttp\Exception\ClientException

Message: Client error: `POST 
https://graph.microsoft.com/beta/users/USER_ID/assignLicense` resulted in a `400 Bad Request` response: { 
"error": { "code": "Request_BadRequest", "message": "One or more parameters 
of the function import 'assig (truncated...)

Filename: /var/www/html/ischooldesarrollo/application/libraries/msgraph-sdk-
php/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php

Line Number: 111

我的错误是什么?

【问题讨论】:

    标签: php microsoft-graph-api


    【解决方案1】:

    几件事:

    1. 不是问题,而是你为什么不使用v1.0
    2. 该方法的有效负载/主体需要 2 个数组参数 - addLicensesremoveLicenses。第二个没看到如果您只是添加许可证,请将 removeLicenses 设置为空数组。
    3. addLicenses 数组是 [disabledPlansskuId] 的数组,disabledPlans 本身就是一个数组。如果您不想禁用任何计划,只需将其设置为空数组即可。

    希望这会有所帮助,

    【讨论】:

    • 我按照你说的做了,`$datos=array("addLicenses"=>array(array("disabledPlans"=>array(), "skuId"=>$sku)), " removeLicenses"=>array() ); ` 错误现在是 404 未找到,Request_ResourceNotFound
    • 抱歉回复晚了。您能否添加对线路上实际情况的跟踪(即 REST 调用)和完整的错误响应(即不仅是 404,还包括客户端请求 ID 和时间戳)。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-07
    • 1970-01-01
    • 2013-12-07
    • 2022-01-18
    • 1970-01-01
    相关资源
    最近更新 更多