I am calling this api to purge web site’s cache,
zones/:identifier/purge_cache
It is working fine in postman.
But I tried to call it from azure devops pipeline:
jobs:
- job: ClearCache
pool: server
steps:
- task: InvokeRESTAPI@1
inputs:
connectionType: 'connectedServiceName'
serviceConnection: 'Purge Dev Cloudflare cache'
method: 'POST'
headers: |
{
"Content-Type":"application/json",
"Authorization": "Bearer ${Token}"
}
body: '{"purge_everything":true}'
waitForCompletion: 'false'
successCriteria: 'eq(root[''success''], ''true'')'
It always returns
==============================================================================
Task : InvokeRESTAPI
Description : Invoke a REST API as a part of your pipeline.
Version : 1.198.0
Author : Microsoft Corporation
==============================================================================
Request body: {
"purge_everything": true
}
Response Code: 0
Response: An error was encountered while processing request. Exception: {"success":false,"errors":[{"code":10000,"message":"Authentication error"}]}
Exception Message: The remote server returned an error: (403) Forbidden. (type WebException)
Evaluation of expression 'eq(root['success'], 'true')' failed.
Exception Message: Error parsing API response into a JSON object. (type DistributedTaskException)
If I switch to zone-list-zones with same headers, it works fine.
The only differences between these two apis are the end point and POST vs GET.
Could anyone help me out? Thanks.