Getting an error when trying to create an order.

LifeRock316
Member
Member

This is the result I am getting. 

    {"name":"UNSUPPORTED_MEDIA_TYPE","message":"The request payload is not supported","debug_id":"7c273243e9c3a","details":[],"links":[]}

The code is: 

 

internal static async Task<string> CreateOrder(string? accessToken)
{
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;

using (HttpClient client = new HttpClient())
{
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
client.DefaultRequestHeaders.AcceptLanguage.Add(new StringWithQualityHeaderValue("en_US"));
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);

List<KeyValuePair<string, string>> keyValues = new List<KeyValuePair<string, string>>();
keyValues.Add(new KeyValuePair<string, string>("body", @"{""intent"": ""CAPTURE"", ""purchase_units"": [{""reference_id"": ""d9f80740-38f0-11e8-b467-0ed5f89f718b"", ""amount"": {""currency_code"": ""USD"", ""value"": ""100.00""}"));
var responseMessage = await client.PostAsync("https://api.sandbox.paypal.com/v2/checkout/orders", new FormUrlEncodedContent(keyValues));
string response = await responseMessage.Content.ReadAsStringAsync();
return response;
}
}

Login to Me Too
1 REPLY 1

Kavyar
Moderator
Moderator

Good day @LifeRock316 

 

Thank you for posting to the PayPal community.

 

Based on the information provided, it appears that the error is most likely due to syntax issues in the request you are passing. We highly recommend thoroughly reviewing and double-checking the URL and request body for any syntax errors.

 

To assist you with troubleshooting this issue, we have provided detailed guide links below.

 

https://developer.paypal.com/api/rest/reference/orders/v2/errors/

 

NOT_SUPPORTED: This field is not currently supported. Possible error locations:

payer/address/*

payer/name/*

payer/phone/phone number/*

purchase_units/0/shipping/address/*

purchase_units/0/shipping/name/*

 

Please follow these guidelines to ensure that the URL syntax is correct, and all required fields are properly formatted.

 

Note: Please note that it is important to utilize the token within 24 hours. If it is not used within this timeframe, you will need to generate a new token.

 

If you are still experiencing issues, please create an MTS ticket via the following URL - https://www.paypal-support.com/s/?language=en_US . Please ensure that you provide detailed information and error details when submitting the ticket.

 

Sincerely,

Kavya

PayPal MTS

 

If this post or any other was helpful, please enrich the community by giving kudos or accepting it as a solution.

Login to Me Too

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.