首页 > 解决方案 > Azure Devops YAML:无效的 JavaScript 属性标识符字符 yaml

问题描述

使用 Azure DevOps YAML 任务“Invoke-HTTP”,我不断得到 Exception message 'Exception Message: Invalid JavaScript property identifier character: -. Path '', line 1, position 8. (type JsonReaderException)'

这是任务的文档:

https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/utility/http-rest-api?view=azure-devops

脚本如下: jobs: # Publish resource group artifact - job: invoke_http_for_ase pool: server continueOnError: true steps: # Invoke REST API # Invoke a REST API as a part of your pipeline. - task: InvokeRESTAPI@1 displayName: 'GET Member' inputs: connectionType: 'connectedServiceNameARM' azureServiceConnection: 'ARM-Service-Connection' method: 'GET' headers: '{Content-Type:application/json}' urlSuffix: "subscriptions/xxx/resourceGroups/xxx?api-version=2018-05-01" waitForCompletion: 'true'

设计师在发布管道中使用发布任务也同样有效。

标签: azure-devopsyaml

解决方案


问题在于标头值必须是有效的 JSON,即属性名称和值必须用引号引起来。看到这个 github 问题


推荐阅读