Make a request to get page HTML, especially the etag:
$ curl -I 'https://en.wikipedia.org/w/rest.php/v1/page/Wikipedia%3ASandbox/html' HTTP/2 200 date: Wed, 27 Dec 2023 01:48:15 GMT server: mw1491.eqiad.wmnet x-content-type-options: nosniff cache-control: max-age=5 content-language: en content-revision-id: 1191998422 access-control-allow-origin: * vary: Accept-Encoding last-modified: Wed, 27 Dec 2023 01:40:37 GMT content-type: text/html; charset=utf-8; profile="https://www.mediawiki.org/wiki/Specs/HTML/2.8.0" etag: W/"1191998422/efa972fc-a458-11ee-8729-c1319dbdd51a/view/html" age: 0 x-cache: cp1106 miss, cp1106 miss x-cache-status: miss server-timing: cache;desc="miss", host;desc="cp1106" strict-transport-security: max-age=106384710; includeSubDomains; preload report-to: { "group": "wm_nel", "max_age": 604800, "endpoints": [{ "url": "https://intake-logging.wikimedia.org/v1/events?stream=w3c.reportingapi.network_error&schema_uri=/w3c/reportingapi/network_error/1.0.0" }] } nel: { "report_to": "wm_nel", "max_age": 604800, "failure_fraction": 0.05, "success_fraction": 0.0} set-cookie: WMF-Last-Access=27-Dec-2023;Path=/;HttpOnly;secure;Expires=Sun, 28 Jan 2024 00:00:00 GMT set-cookie: WMF-Last-Access-Global=27-Dec-2023;Path=/;Domain=.wikipedia.org;HttpOnly;secure;Expires=Sun, 28 Jan 2024 00:00:00 GMT x-client-ip: 74.71.26.214 set-cookie: GeoIP=US:NY:New_York:40.80:-73.98:v4; Path=/; secure; Domain=.wikipedia.org set-cookie: NetworkProbeLimit=0.001;Path=/;Secure;Max-Age=3600 accept-ranges: bytes
Now try and convert some HTML back, in this case the payload doesn't matter:
$ curl -X POST -H "Content-Type: application/json" -H 'if-match: W/"1191998422/efa972fc-a458-11ee-8729-c1319dbdd51a/view/html"' --data '{ "html": "what" }' 'https://en.wikipedia.org/w/rest.php/v1/transform/html/to/wikitext/Wikipedia%3ASandbox' {"message":"No stashed content found for 1191998422/efa972fc-a458-11ee-8729-c1319dbdd51a","httpCode":412,"httpReason":"Precondition Failed"}
If I drop the if-match header it works fine.
Based on T350219#9326501 I suspect this is a Documentation issue and the stash parameter needs to be used, except it's not documented anywhere I can find (e.g. https://www.mediawiki.org/wiki/API:REST_API/Reference). Is it safe to use unconditionally?