Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.8k views
in Technique[技术] by (71.8m points)

azure - Step references task InvokeRESTAPI at version 1.152.1 which is not valid for the given job target

I have an Azure pipeline which needs to send a REST request to an endpoint. I am trying to use the built in task InvokeRESTAPI@1 to do this, but it errors when running on Azure DevOps.

Script:

---
trigger:
  batch: true
  branches:
    include:
      - master
pr:
  - master

stages:
  - stage: Run_Tests
    jobs:
      - job: RA001
        pool: windows-server
        steps:
          - task: InvokeRESTAPI@1
            displayName: "Run Test"
            inputs:
              connectionType: 'connectedServiceName'
              serviceConnection: 'myconnection'
              method: 'PUT'
              headers: |
                {
                "AccessKey":"$(system.MyKey)"
                }
              urlSuffix: '/api/v3/schedules/uniquenumber/runNow'
              waitForCompletion: 'false'

Returns:

Job RA001: Step references task 'InvokeRESTAPI' at version '1.152.1' which is not valid for the given job target.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The InvokeRESTAPI@1 it's server job task (agentless job in the classic editor), not a regular task that can run on an agent.

You need to put it in server job in this way:

pool: server

More info you can find here.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...