<p></p>
<blockquote>
<p dir="auto">Presumably, you're sending your request with a Content-Type application/x-www-form-urlencoded or something similar, in which case the request fails with HTTP 400.</p>
</blockquote>
<p dir="auto">I was investigating this yesterday, and came to the same conclusion. In fact, it's easily reproduced in our test suite, since the put requests fail with the same 400 response if you add a % character:</p>
<div class="highlight highlight-source-diff" dir="auto"><pre class="notranslate"> xml = "<osm><changeset>" \
<span class="pl-md"><span class="pl-md">-</span> "<tag k='created_by' v='osm test suite checking changesets'/>" \</span>
<span class="pl-mi1"><span class="pl-mi1">+</span> "<tag k='created_by' v='osm test suite checking changesets%'/>" \</span>
"</changeset></osm>"</pre></div>
<pre class="notranslate"><code class="notranslate">Failure:
Api::ChangesetsControllerTest#test_create [/home/andy/src/openstreetmap-website/test/controllers/api/changesets_controller_test.rb:82]:
Creation of changeset did not return success status
</code></pre>
<pre class="notranslate"><code class="notranslate">Started PUT "/api/0.6/changeset/create" for 127.0.0.1 at 2024-01-11 09:52:24 +0000
Rack::QueryParser::InvalidParameterError (invalid %-encoding ('created_by' v='osm test suite checking changesets%'/></changeset></osm>))
</code></pre>
<p dir="auto">If we add a "Content-Type: application/xml" header to the <code class="notranslate">put</code> request in the test suite, then that stops Rack from treating it as url-encoded payload, and correctly treats it as XML.</p>
<p dir="auto">So the first step is as <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/mmd-osm/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/mmd-osm">@mmd-osm</a> explains - the client application should set the correct content-type header, and then it will hopefully work fine.</p>
<p dir="auto">The second step is to open the discussion about whether we should set a default content-type for the API. This is one of these things were someone has built their client application, and it's worked fine without it, until someone hits an edge case and it breaks. Should we treat all requests to the XML api as application/xml by default, to avoid this from happening? Or should we start throwing errors for incorrect content types, so that developers find this out during testing rather than user reports year(s) later?</p>
<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />Reply to this email directly, <a href="https://github.com/openstreetmap/openstreetmap-website/issues/4467#issuecomment-1886759718">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AAK2OLMLTP6342QXELAZKZTYN6Z3LAVCNFSM6AAAAABBTZVT7SVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOBWG42TSNZRHA">unsubscribe</a>.<br />You are receiving this because you are subscribed to this thread.<img src="https://github.com/notifications/beacon/AAK2OLIPCVKR3BMHZJXHUQ3YN6Z3LA5CNFSM6AAAAABBTZVT7SWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTTQOWVSM.gif" height="1" width="1" alt="" /><span style="color: transparent; font-size: 0; display: none; visibility: hidden; overflow: hidden; opacity: 0; width: 0; height: 0; max-width: 0; max-height: 0; mso-hide: all">Message ID: <span><openstreetmap/openstreetmap-website/issues/4467/1886759718</span><span>@</span><span>github</span><span>.</span><span>com></span></span></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/openstreetmap/openstreetmap-website/issues/4467#issuecomment-1886759718",
"url": "https://github.com/openstreetmap/openstreetmap-website/issues/4467#issuecomment-1886759718",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>