Fraize_Websleuths
New member
I've been trying to integrate my mailing-list unsubscribes with my Xenforo back-end using the REST API, but can't seem to update the user's receive_admin_email field. I'm hoping some kind soul can point me in the right direction.
The response-codes are always 200, but the field is never updated from true to false.
For reference, I'm using a SuperUser Key with Xf-Api-User set to my own Admin account. The key has user-read and user-write privileges. The function is below, with the response body below that.
The (redacted) response body for this particular user is:
For what it's worth, I also tried doing this with curl:
The response-codes are always 200, but the field is never updated from true to false.
For reference, I'm using a SuperUser Key with Xf-Api-User set to my own Admin account. The key has user-read and user-write privileges. The function is below, with the response body below that.
Python:
def update_receive_admin_email(user_id):
url = f"{API_BASE_URL}/users/{user_id}"
data = "option[receive_admin_email]=false"
response = requests.post(url, headers=HEADERS, data=data)
# debug only - print(response.content)
return response.status_code == 200
The (redacted) response body for this particular user is:
JSON:
{
"success": true,
"user": {
"about": "",
"activity_visible": true,
"alert_optout": [],
"allow_post_profile": "members",
"allow_receive_news_feed": "everyone",
"allow_send_personal_conversation": "members",
"allow_view_identities": "everyone",
"allow_view_profile": "members",
"avatar_urls": {
"o": null,
"h": null,
"l": null,
"m": null,
"s": null
},
"can_ban": false,
"can_converse": false,
"can_edit": true,
"can_follow": true,
"can_ignore": true,
"can_post_profile": true,
"can_view_profile": true,
"can_view_profile_posts": true,
"can_warn": true,
"content_show_signature": true,
"creation_watch_state": "watch_no_email",
"custom_fields": {
"gender": "male"
},
"custom_title": "",
"dob": {
"year": null,
"month": 11,
"day": 27
},
"email": "redacted@gmail.com",
"email_on_conversation": true,
"gravatar": "",
"interaction_watch_state": "watch_no_email",
"is_admin": false,
"is_banned": true,
"is_discouraged": false,
"is_followed": false,
"is_ignored": false,
"is_moderator": false,
"is_staff": false,
"is_super_admin": false,
"last_activity": 1536656529,
"location": "",
"message_count": 0,
"profile_banner_urls": {
"l": null,
"m": null
},
"push_on_conversation": true,
"push_optout": [],
"question_solution_count": 0,
"reaction_score": 0,
"receive_admin_email": true,
"register_date": 1535563151,
"secondary_group_ids": [
10,
16
],
"show_dob_date": true,
"show_dob_year": false,
"signature": "",
"timezone": "America/Los_Angeles",
"trophy_points": 1,
"use_tfa": false,
"user_group_id": 2,
"user_id": 654321,
"user_state": "valid",
"user_title": "Former Member",
"username": "redactedusername",
"view_url": "https://redacted.com/members/redactedusername.654321/",
"visible": true,
"vote_score": 0,
"warning_points": 10,
"website": ""
}
}
For what it's worth, I also tried doing this with curl:
Bash:
curl -X POST https://redacted.com/api/users/123456 \
-H "XF-Api-Key: redacted" \
-H "XF-Api-User: 654321" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "option[receive_admin_email]=false"