I'm trying to write a script to remove me from courses that I get enrolled in as an admin when I create a new course. I'm trying to use the Python Requests to delete the enrollment. When I do it through my python script, it only concludes the enrollment (so it stays on my list) instead of deleting it. At least then I'm not getting notifications or visible to students.
json_headers <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">{</SPAN><SPAN class="string token">'Authorization'</SPAN> <SPAN class="punctuation token">:</SPAN> <SPAN class="string token">'Bearer '</SPAN> <SPAN class="operator token">+</SPAN> api_token<SPAN class="punctuation token">}</SPAN><BR /><BR /><BR /><SPAN class="keyword token">def</SPAN> <SPAN class="token function">api_unenroll_admin_course</SPAN><SPAN class="punctuation token">(</SPAN>course_id<SPAN class="punctuation token">,</SPAN> enrollment_id<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN><BR /> enroll_url <SPAN class="operator token">=</SPAN> url <SPAN class="operator token">+</SPAN> <SPAN class="string token">"/courses/"</SPAN> <SPAN class="operator token">+</SPAN> str<SPAN class="punctuation token">(</SPAN>course_id<SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">"/enrollments/"</SPAN> <SPAN class="operator token">+</SPAN> str<SPAN class="punctuation token">(</SPAN>enrollment_id<SPAN class="punctuation token">)</SPAN><BR /> <SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN>enroll_url<SPAN class="punctuation token">)</SPAN><BR /> payload <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">{</SPAN><SPAN class="string token">'enrollment[task]'</SPAN> <SPAN class="punctuation token">:</SPAN> <SPAN class="string token">'delete'</SPAN><SPAN class="punctuation token">}</SPAN><BR /> <SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN>payload<SPAN class="punctuation token">)</SPAN><BR /> r_delete <SPAN class="operator token">=</SPAN> requests<SPAN class="punctuation token">.</SPAN>delete<SPAN class="punctuation token">(</SPAN>enroll_url<SPAN class="punctuation token">,</SPAN> headers<SPAN class="operator token">=</SPAN>json_headers<SPAN class="punctuation token">,</SPAN> data<SPAN class="operator token">=</SPAN>payload<SPAN class="punctuation token">)</SPAN><BR /> <SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN>r_delete<SPAN class="punctuation token">.</SPAN>text<SPAN class="punctuation token">)</SPAN><BR /> <SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN>r_delete<SPAN class="punctuation token">.</SPAN>url<SPAN class="punctuation token">)</SPAN><BR /> <SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN>r_delete<SPAN class="punctuation token">)</SPAN><BR /><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>when I do it using PostMan as shown below, it actually deletes the enrollment (but I have to go look up each enrollment ID and then go run each delete call).

Does anyone have ideas about what I am doing wrong? I think I'm leaving something out of the python code but not sure what.
Thanks!
Joni