【问题标题】:Cannot set content-type in header for azure pipelines task无法在 azure 管道任务的标头中设置内容类型
【发布时间】:2021-07-30 16:03:01
【问题描述】:

我正在构建调用端点的天蓝色管道任务。但是我不断收到错误“不支持的媒体类型 415”。这是我的代码

   "dataSources": [
    {
      "name": "ProjectsEP",     

       "endpointUrl": "{{endpoint.url}}/api/project/projects",
       "requestVerb": "Post",
       "resultSelector": "jsonpath:",
       "requestContent":"",
       "headers": [
       {
          "name": "Content-Type",
          "value": "application/json"
        }
     ] 
 }

"dataSourceBindings": [
  {
   "target": "project",
   "endpointId": "$(FabrikamService)",
   "dataSourceName": "ProjectsEP",
    "requestVerb": "Post"
  }]

我需要将内容类型更改为“application/json”。

同样的请求也适用于邮递员

我在这里错过了什么?

【问题讨论】:

    标签: azure-devops azure-pipelines azure-pipelines-tasks


    【解决方案1】:

    您可以尝试以下格式来设置标题并检查它是否可以工作:

    "headers": "{\n\"Content-Type\":\"application/json\", \n\"Authorization\": \"Bearer  $(system.accesstoken)\"\n}"
    

    这是example,你可以参考一下。

    【讨论】:

      猜你喜欢
      • 2019-03-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-02-01
      相关资源
      最近更新 更多