Skip to content

Commit

Permalink
Fix XML encoding on changeset upload #487
Browse files Browse the repository at this point in the history
  • Loading branch information
frodrigo committed Mar 9, 2024
1 parent 4cdab9d commit 6d90360
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions web_api/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,11 @@ def _osm_changeset(tags, id: str = "0") -> str:
def _changeset_create(oauth2_token: str, tags: Dict[str, str]) -> str:
request = requests.put(
utils.remote_url_write + "api/0.6/changeset/create",
data=_osm_changeset(tags),
headers={"Authorization": f"Bearer {oauth2_token}"},
data=_osm_changeset(tags).encode(),
headers={
"Authorization": f"Bearer {oauth2_token}",
"Content-Type": "application/xml; charset=utf-8",
},
)
request.raise_for_status()
return request.text
Expand All @@ -121,24 +124,32 @@ def _changeset_create(oauth2_token: str, tags: Dict[str, str]) -> str:
def _changeset_update(oauth2_token: str, id: str, tags: Dict[str, str]) -> None:
request = requests.put(
utils.remote_url_write + "api/0.6/changeset/" + id,
data=_osm_changeset(tags, id=id),
headers={"Authorization": f"Bearer {oauth2_token}"},
data=_osm_changeset(tags, id=id).encode(),
headers={
"Authorization": f"Bearer {oauth2_token}",
"Content-Type": "application/xml; charset=utf-8",
},
)
request.raise_for_status()


def _changeset_close(oauth2_token: str, id: str) -> None:
request = requests.put(
utils.remote_url_write + "api/0.6/changeset/" + id + "/close",
headers={"Authorization": f"Bearer {oauth2_token}"},
headers={
"Authorization": f"Bearer {oauth2_token}",
},
)
request.raise_for_status()


def _changeset_upload(oauth2_token: str, id: str, osmchange) -> None:
request = requests.post(
utils.remote_url_write + "api/0.6/changeset/" + id + "/upload",
data=osmchange,
headers={"Authorization": f"Bearer {oauth2_token}"},
data=osmchange.encode(),
headers={
"Authorization": f"Bearer {oauth2_token}",
"Content-Type": "application/xml; charset=utf-8",
},
)
request.raise_for_status()

0 comments on commit 6d90360

Please sign in to comment.