Reputation: 23
So I am trying to automatically update an azure devops wiki using azure CLI. In order to do so I need to get the wiki etag:
az devops wiki page show\
--path 'my_project - Slab Quality Prediction/test' \
--wiki my_project.wiki \
--query 'eTag'
Output:
"\"1156501f9cxxxxxbdca3456d6xxxxdd63\""
And if I manually copy this output and past in the command
az devops wiki page update\
--path 'my_project - Slab Quality Prediction/test' \
--wiki my_project.wiki \
--version "\"1156501f9cxxxxxbdca3456d6xxxxdd63\"" \
--file-path test.md \
--encoding utf-8
It works perfectly.
Great, now just need to automate that, right?
etag=$(
az devops wiki page show\
--path 'my_project - Slab Quality Prediction/test' \
--wiki my_project.wiki \
--query 'eTag'
)
az devops wiki page update\
--path 'my_project - Slab Quality Prediction/test' \
--wiki my_project.wiki \
--version $etag \
--file-path test.md \
--encoding utf-8 \
--debug &> thebug
Wrong, look at the error.
Error message:
Pre-condition `IfMatch` header provided in the request is an invalid page version. Please provide the version of the wiki page as the `IfMatch` header for the request.
Parameter name: IfMatch
If you look at the debug option, you can see why the error, it's because the etag it is not set correctly:
version that show on debug: ... '--version', '"\\"1156501f9cxxxxxbdca3456d6xxxxdd63\\""', ...
what should be: "\"1156501f9cxxxxxbdca3456d6xxxxdd63\""
I did not foud a way to right format this guy so the bash would understand.
Upvotes: 0
Views: 258
Reputation: 23
In the end it was not needed the (""), so I just use the following commands:
etag=$(
az devops wiki page show\
--path 'my_project - Slab Quality Prediction/test' \
--wiki my_project.wiki \
--query 'eTag'
)
az devops wiki page update\
--path 'my_project - Slab Quality Prediction/test' \
--wiki my_project.wiki \
--version ${etag:3:-3} \
--file-path test.md \
--encoding utf-8
Upvotes: 0