Markdown input/export loss of line breaks

I am trying to automate this file rename but the API gives me errors. If you can advise that would be great. Specifically I am trying to edit the file name using a patch as per Crowdin API Reference (File-based)

My Python code is like this:

# Function to rename a file
def rename_file(file_id, new_name):
    url = f"{BASE_URL}projects/{PROJECT_ID}/files/{file_id}"
    headers = {
        "Authorization": f"Bearer {API_KEY}",
        "Content-Type": "application/json"
    }
    data = {
      "op": "replace",
      "path": "/name",
      "value": new_name
    }
    response = requests.patch(url, headers=headers, json=data)
    print(f"Rename: {file_id} to {new_name}: {response.status_code}")
    pprint.pprint(response.json())
    return response.json()

# Rename a file
rename_file(3754, 'old_index.md')

But if I do a patch I get the error

400
{'errors': [{'error': {'errors': [{'code': 'jsonPatchInvalid',
                                   'message': 'Invalid operation given'}],
                       'key': 'op'}}, ...

And if I change the patch to a put I get the error

400
{'errors': [{'error': {'errors': [{'code': 'unexpected',
                                   'message': "Field 'op' is unexpected"}],
                       'key': 'op'}},
            {'error': {'errors': [{'code': 'unexpected',
                                   'message': "Field 'path' is unexpected"}],
                       'key': 'path'}},
            {'error': {'errors': [{'code': 'unexpected',
                                   'message': "Field 'value' is unexpected"}],
                       'key': 'value'}}]}

The format of the operation with op seems to match the docs, so I’m confused.