We are currently testing the RedirectRules API in Early Access. We use Python for that my code looks equal to the sample in the API documentation, excluding the authentication. This is because we use SingleSignOn. This works with other scripts we use. Thus I would exclude this as cause.
import requests
import json
zendesk_subdomain = 'xxx'
zendesk_authorization = 'Basic xxx'
url = 'https://' + zendesk_subdomain + '.zendesk.com/api/v2/guide/redirect_rules'
# Set the request headers
headers = {
'Authorization': zendesk_authorization,
'content-type': 'application/json'
}
payload = json.loads("""{
"redirect_rule": {
"redirect_from": "/hc/en-us/articles/4403403468690",
"redirect_status": 301,
"redirect_to": "https://<our_domain>/contact_us"
}
}""")
response = requests.request(
"POST",
url,
headers=headers,
json=payload
)
# Check for HTTP codes other than 200
if response.status_code != 200:
print('Problem with the request.')
print('Status:', response.status_code)
print('reason:', response.reason)
print('content:', response.content)
exit()
# Report success
print('Successfully redirected')
I get following response
Problem with the request.
Status: 204
reason: No Content
content: b''
If I search afterwards for Redirect Rules, it is shown, but the redirect didn't work.
Deleting the Redirect Rule using the API also returns a 204, but the Redirect Rule cannot be found with the search afterwards.
Any hints?