Error code 415 : Unsupported Media Type' - occures when: using API to cancel Paypal subscription
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear Community,
I have spent the whole day trying to cancel a Paypal subscription by code. All the time I keep geting the response: Error 415 Unsupported Media Type. I have turned google up and down to find a solution, uselessly. I am using the follwoing C#.Net code:
string url = "https://api-m.paypal.com/v1/billing/subscriptions/" + subscription_ID + "/cancel";
var client = new HttpClient();
var msg = new HttpRequestMessage(HttpMethod.Post, url);
msg.Headers.Authorization = new AuthenticationHeaderValue("Bearer", txt.Text);
msg.Content = new StringContent(JsonConvert.SerializeObject("reason: Item out of stock"));// I have tried either the not using of this convert uselessly
var response = client.SendAsync(msg).Result;
---
Kindly, what to do ?
Thanks,
Peter

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @PeterKhaled
Thank you for posting to the PayPal Community.
I noticed in your request new AuthenticationHeaderValue("Bearer", txt.Text);
This file type: txt.Text is most likely causing the 415 error message. Our server will not recognize a .txt file, so if you are writing your bearer token to a .txt file, it will not be read by the PayPal server. Please pass your token in the request, not as a file.
Thank you,
Jennifer
MTS
PayPal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Haven't Found your Answer?
It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.