繁体   English   中英

Invoke-RestMethod 补丁在 Azure DevOps 中引发错误

[英]Invoke-RestMethod Patch throws error in Azure DevOps

我在更新 Intune 设备脚本时遇到问题。 我的代码在本地机器上运行 VS 代码时有效,但在通过 Azure DevOps Pipeline 运行时出错。

$updateURI: https://graph.microsoft.com/beta/deviceManagement/deviceManagementScripts/c24***********6a

$邮递员:

{
    $Resource = "deviceManagementScripts"
    $ODataType = "#microsoft.graph.deviceManagementScript"
    $postbody = @{
        "@odata.type" = $ODataType; 
        "displayName" = $Displayname;
        "description" = $Description;
        "scriptContent" = $UploadScriptEncoded;
        "runAsAccount" = "user";
        "enforceSignatureCheck" = "false";
        "fileName" = $Filename } | ConvertTo-Json
}

休息方法:

Invoke-RestMethod -Uri $updateURI -Headers $authHeader -Method Patch -Body $postbody -ContentType "application/JSON"

错误:

调用-RestMethod:/Users/runner/work/1/s/inline.ps1:111 行 | 111 | Invoke-RestMethod -Uri $updateURI -Headers $authHeader -Method Patch ... | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| {"error":{"code":"BadRequest","message":"{\r\n "_version": | 3,\r\n "Message":"发生错误 - 操作 ID | (用于客户支持):00000000-0000-0000-0000-000000000000 - | 活动 ID:c27be3e1-4de1-43c2-8f5d-9db86608b2a7 - Url:| https://fef.amsua0202.manage.microsoft.com/DeviceFE/StatelessDeviceFEService/deviceManagement/deviceManagementScripts%28%274ce72c8b-1086-404d-8c9f-db9ff8b95d35%27%29?api-version=5021-03,” \r\n "CustomApiErrorPhrase": "",\r\n "RetryAfter": null,\r\n "ErrorSourceService": "",\r\n "HttpHeaders": "{}"\r\n}" ,"innerError":{"date":"2021-04-23T21:42:36","request-id":"c27be3e1-4de1-43c2-8f5d-9db86608b2a7","client-request-id":"c27be3e1 -4de1-43c2-8f5d-9db86608b2a7"}}}

##[错误]PowerShell 以代码“1”退出。

XML:

<ODataError xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/Microsoft.OData.Core">
<Details i:nil="true"/>
<ErrorCode>UnsupportedApiVersion</ErrorCode>
<InnerError i:nil="true"/>
<InstanceAnnotations/>
<Message>{ "_version": 3, "Message": "An error has occurred - Operation ID (for customer support): 00000000-0000-0000-0000-000000000000 - Activity ID: d7777c39-60cd-46e3-bca0-a24148d2ccb6 - Url: https://fef.amsua0202.manage.microsoft.com/DeviceFE/StatelessDeviceFEService/deviceManagement/deviceManagementScripts%28%274ce72c8b-1086-404d-8c9f-db9ff8b95d35%27%29?api-version=5021-03-18%5C%22,%5Cr%5Cn", "CustomApiErrorPhrase": "", "RetryAfter": null, "ErrorSourceService": "", "HttpHeaders": "{}" }</Message>
<Target i:nil="true"/>
</ODataError>

请在这里帮助理解我错过了什么。 提前致谢。

请尝试删除$postbody postbody 中的@odata.type参数并再次运行它。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM